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

**URL:** <https://www.ruby-forum.com/t/routing-error-for-css-js-image-files-others-fine/134646>\
**Category:** Rails\
**Created:** [April 13, 2008, 12:03pm UTC](https://www.ruby-forum.com/t/routing-error-for-css-js-image-files-others-fine/134646 "2008-04-13T12:03:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebdb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/48db29/32.png) [@ebdb](https://www.ruby-forum.com/u/ebdb)\
**Post date:** [April 13, 2008, 12:03pm UTC](https://www.ruby-forum.com/t/routing-error-for-css-js-image-files-others-fine/134646/1 "2008-04-13T12:03:21Z")

</div>

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:in`recognize’

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

---

<div class="post-metadata">

**Author:** ![ebdb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/48db29/32.png) [@ebdb](https://www.ruby-forum.com/u/ebdb)\
**Post date:** [April 13, 2008, 3:51pm UTC](https://www.ruby-forum.com/t/routing-error-for-css-js-image-files-others-fine/134646/2 "2008-04-13T15:51:14Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![ebdb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/48db29/32.png) [@ebdb](https://www.ruby-forum.com/u/ebdb)\
**Post date:** [April 13, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/routing-error-for-css-js-image-files-others-fine/134646/3 "2008-04-13T23:08:59Z")

</div>

> 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

---

<div class="post-metadata">

**Author:** ![ebdb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/48db29/32.png) [@ebdb](https://www.ruby-forum.com/u/ebdb)\
**Post date:** [May 8, 2008, 8:04pm UTC](https://www.ruby-forum.com/t/routing-error-for-css-js-image-files-others-fine/134646/4 "2008-05-08T20:04:47Z")

</div>

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](http://benr75.com/articles/2008/04/12/setup-mod_rails-phusion-mac-os-x-leopard)
