Routing error for .css, .js, image files. Others fine

I have a Rails 2.0.2 app that’s working fine locally on my Mac using
Webrick. However, deployed to my CentOS 5 production server I’m
getting routing errors for .css files, .js, and for images. The
actions are working fine on production though, so the links in my menu
bar for example all go to the locations expected, there’s just no CSS
or JS happening. Just these “asset” files have errors.

I’m deploying to mod_rails under Apache.

Here is an example:

ActionController::RoutingError (No route matches “/stylesheets/
styles.css” with {:method=>:get}):
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/routing.rb:1441:in recognize_path' /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/routing.rb:1424:inrecognize’

I have not changed anything in my routes.rb file since I created the
app, except to set the root route. Everything else is stock.

You can have the root of your site routed with map.root – just

remember to delete public/index.html.
map.root :controller => “card”

Does anyone have an idea what’s happening with this?

Thanks,

ebdb

ebdb,

Since mod_rails was just released, I don’t know how much experience is
out there using it. You really should check “over there”:
http://groups.google.com/group/phusion-passenger and see if there is
anything people can suggest.

FWIW, I suspect that it’s nothing to do with your Rails app and is
rather an apache or mod_rails config. It shouldn’t be passing “/
stylesheets/styles.css” to the rails routing engine. Those should be
intercepted and served statically by apache, I’d assume.

When you are running Webrick, it is the only “app” running, so it
handles everything, using the .htaccess file in “/public” to determine
what to do. There should be something similar in terms of URL
rewriting/intercepting for mod_rails (or even just part of Apache).

But as I haven’t played with mod_rails, I’m not sure what it would be.

-Danimal

FWIW, I suspect that it’s nothing to do with your Rails app and is
rather an apache or mod_rails config. It shouldn’t be passing “/
stylesheets/styles.css” to the rails routing engine. Those should be
intercepted and served statically by apache, I’d assume.

When you are running Webrick, it is the only “app” running, so it
handles everything, using the .htaccess file in “/public” to determine
what to do. There should be something similar in terms of URL
rewriting/intercepting for mod_rails (or even just part of Apache).

Thanks for the info. It’s probably something like that. I’ll look more
closely at my Apache config.

E

I was having the same problem with my css files. All I needed to do
was remove the default .htaccess file from the public directory of my
rails app. After that, everything appears to be working. Hope that
helps.

This is the article that mentioned removing your .htaccess file:
http://benr75.com/articles/2008/04/12/setup-mod_rails-phusion-mac-os-x-leopard

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs