# Images / stylesheets not loading

**URL:** <https://www.ruby-forum.com/t/images-stylesheets-not-loading/153069>\
**Category:** Rails\
**Created:** [November 11, 2008, 9:08pm UTC](https://www.ruby-forum.com/t/images-stylesheets-not-loading/153069 "2008-11-11T21:08:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marli03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@marli03](https://www.ruby-forum.com/u/marli03)\
**Post date:** [November 11, 2008, 9:08pm UTC](https://www.ruby-forum.com/t/images-stylesheets-not-loading/153069/1 "2008-11-11T21:08:03Z")

</div>

when I use image\_tag or a stylesheet tag, the underlying images or  
stylesheets aren’t loading. Everything used to work properly, but I ran  
into some errors and have had to change some settings, but nothing  
relating to image\_tag or the stylesheet tag.

It produces this error in the log when trying to process the image:

## ---------------------log/development.rb--------------------- Processing CatalogController#unknown\_request (for 71.16.212.90 at 2008-11-11 13:02:03) [GET] Session ID: 107f3aa7e7cd544111699d9180b38916 Parameters: {“action”=\>“unknown\_request”, “controller”=\>“catalog”, “remainder”=\>[“images”, “products”, “107-440.jpg”]} Rendering template within layouts/catalog Rendering catalog/unknown\_request Completed in 0.00398 (251 reqs/sec) | Rendering: 0.00210 (52%) | DB: 0.00022 (5%) | 200 OK [[http://www.mywebsite.com/bpc/images/products/107-440.jpg](http://www.mywebsite.com/bpc/images/products/107-440.jpg)]

my image tag usage seems to be correct:

## ----------------------product.html.erb------------------------- \<% if !@product.pictures.empty? %\> \<% @product.pictures.each do |picture| %\> \<%= image\_tag(picture.location) %\> \<% end %\> \<% end %\>

and here is the resulting html:

* * *

```
<div class='product_picture'>
  <img alt="107-440" src="/bpc/images/products/107-440.png" />
  <img alt="107-440" src="/bpc/images/products/107-440.jpg" />
</div>

```

* * *

I really am lost over what i need to do to fix this. Any ideas? It  
looks like it’s now treating the image\_tag as a url request somehow and  
sending it into my catchall unknown\_request route.

---

<div class="post-metadata">

**Author:** ![marli03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@marli03](https://www.ruby-forum.com/u/marli03)\
**Post date:** [November 12, 2008, 6:40pm UTC](https://www.ruby-forum.com/t/images-stylesheets-not-loading/153069/2 "2008-11-12T18:40:35Z")

</div>

On Nov 11, 2008, at 12:08 PM, Marli Ba wrote:

> ## ---------------------log/development.rb---------------------
> 
> \<% end %\>
> 
> I really am lost over what i need to do to fix this. Any ideas? It  
> looks like it’s now treating the image\_tag as a url request somehow  
> and  
> sending it into my catchall unknown\_request route.

I realize this might be obvious, but does RAILS\_ROOT/public/bpc/images/  
products/107-440.png exist in the filesystem?

---

<div class="post-metadata">

**Author:** ![marli03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@marli03](https://www.ruby-forum.com/u/marli03)\
**Post date:** [November 12, 2008, 9:10pm UTC](https://www.ruby-forum.com/t/images-stylesheets-not-loading/153069/3 "2008-11-12T21:10:50Z")

</div>

Philip H. wrote:

> On Nov 11, 2008, at 12:08 PM, Marli Ba wrote:
> 
> > ## ---------------------log/development.rb---------------------
> > 
> > \<% end %\>
> > 
> > I really am lost over what i need to do to fix this. Any ideas? It  
> > looks like it’s now treating the image\_tag as a url request somehow  
> > and  
> > sending it into my catchall unknown\_request route.
> 
> I realize this might be obvious, but does RAILS\_ROOT/public/bpc/images/  
> products/107-440.png exist in the filesystem?

Yes, I did check that. I wish that was the problem. I think I’m  
getting closer to figuring it out though, I think it might have  
something to do with my dispatch.fcgi file.

---

<div class="post-metadata">

**Author:** ![marli03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@marli03](https://www.ruby-forum.com/u/marli03)\
**Post date:** [November 13, 2008, 4:10pm UTC](https://www.ruby-forum.com/t/images-stylesheets-not-loading/153069/4 "2008-11-13T16:10:29Z")

</div>

Well I think I’ve sortof figured it out if anyone else is having a  
similar problem.

The error was a:  
ActionController::RoutingError (No route matches …

to fix it, I had to edit my .htaccess file.

It seems that in most cases you are supposed to change this line:  
RewriteRule ^(._)$ dispatch.cgi [QSA,L]  
To this line:  
RewriteRule ^(._)$ dispatch.fcgi [QSA,L]

But when I changed it back, now everything seems to be working fine.  
Since I think I’m supposed to be using the fcgi instead of cgi I need to  
look into it a little more to find out why this is happening.

---

<div class="post-metadata">

**Author:** ![marli03](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/59ef9b/32.png) [@marli03](https://www.ruby-forum.com/u/marli03)\
**Post date:** [November 13, 2008, 4:27pm UTC](https://www.ruby-forum.com/t/images-stylesheets-not-loading/153069/5 "2008-11-13T16:27:19Z")

</div>

okay now i got fastcgi working again. i think it ultimately was a  
problem with order of commands in the .htaccess file. I’ve included my  
.htaccess file below if anyone else has this type of problem.

-----------------------------.htaccess-------------------------

# General Apache options

# AddHandler fastcgi-script .fcgi

AddHandler fcgid-script .fcgi  
AddHandler cgi-script .cgi  
Options +FollowSymLinks +ExecCGI

# If you don’t want Rails to look in certain directories,

# use the following rewrite rules so that Apache won’t rewrite certain

requests

# 

# Example:

# RewriteCond %{REQUEST\_URI} ^/notrails.\*

# RewriteRule .\* - [L]

# Redirect all requests not available on the filesystem to Rails

# By default the cgi dispatcher is used which is very slow

# 

# For better performance replace the dispatcher with the fastcgi one

# 

# Example:

# RewriteRule ^(.\*)$ dispatch.fcgi [QSA,L]

RewriteEngine On

# If your Rails application is accessed via an Alias directive,

# then you MUST also set the RewriteBase in this htaccess file.

# 

# Example:

# Alias /myrailsapp /path/to/myrailsapp/public

# RewriteBase /myrailsapp

RewriteRule ^$ index.html [QSA]  
RewriteRule ^([^.]+)$ $1.html [QSA]  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^(.\*)$ dispatch.fcgi [QSA,L]

# RewriteRule ^(.\*)$ dispatch.cgi [QSA,L]

# In case Rails experiences terminal errors

# Instead of displaying this message you can supply a file here which

will be rendered instead

# 

# Example:

# ErrorDocument 500 /500.html

ErrorDocument 500 “

## Application error
Rails application failed to  
start properly”
