Images / stylesheets not loading


#1

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]

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.


#2

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?


#3

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.


#4

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.


#5

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”