# Routing Error with Passenger for Images and stylesheets

**URL:** <https://www.ruby-forum.com/t/routing-error-with-passenger-for-images-and-stylesheets/169169>\
**Category:** Rails\
**Created:** [May 30, 2009, 7:13pm UTC](https://www.ruby-forum.com/t/routing-error-with-passenger-for-images-and-stylesheets/169169 "2009-05-30T19:13:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [May 30, 2009, 7:13pm UTC](https://www.ruby-forum.com/t/routing-error-with-passenger-for-images-and-stylesheets/169169/1 "2009-05-30T19:13:55Z")

</div>

Hi,

I updated my server with the latest Rails (2.3.2) and Passenger (2.2.2).  
I also updated my Rails app to run under 2.3.2. It runs  
fine locally under Mongrel.

The app is deployed into my own home directory under: (deployed via  
Capistrano)  
/users/me/public\_html/myapp/current (which is a symlink to the  
actual app)  
and it’s accessed by the url:  
[http://myserver.com/myapp](http://myserver.com/myapp)

I was getting routing errors, where Passenger/Apache could not find the  
default route. But I found a post saying Passenger  
has an issue with routing, so I added the RailsBaseURI to the  
environment.rb file:

config.action\_controller.relative\_url\_root = “/myapp”

I found another post that said my apache config should be:

\<VirtualHost \*:80\>  
ServerName [myserver.com](http://myserver.com)  
DocumentRoot /home/me/public\_html/myapp/current/public  
\<Directory “/home/me/public\_html/myapp/current/public”\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all  
  
RailsBaseURI /

I have not .htaccess file in the public folder.

I am now able to get to the app, but all references to stylesheets and  
images are giving routing errors in the  
production.log file:

Processing ApplicationController#index (for 1.2.3.4 at 2009-05-30  
13:11:46) [GET]

ActionController::RoutingError (No route matches  
“/stylesheets/scaffold.css” with {:method=\>:get}):  
passenger (2.2.2) lib/phusion\_passenger/rack/request\_handler.rb:81:in  
`process_request' passenger (2.2.2) lib/phusion_passenger/abstract_request_handler.rb:203:in `main\_loop’  
passenger (2.2.2)  
lib/phusion\_passenger/railz/application\_spawner.rb:340:in  
`start_request_handler' passenger (2.2.2) lib/phusion_passenger/railz/application_spawner.rb:298:in `handle\_spawn\_application’  
passenger (2.2.2) lib/phusion\_passenger/utils.rb:181:in `safe_fork' passenger (2.2.2) lib/phusion_passenger/railz/application_spawner.rb:296:in `handle\_spawn\_application’  
passenger (2.2.2) lib/phusion\_passenger/abstract\_server.rb:337:in  
` __send__' passenger (2.2.2) lib/phusion_passenger/abstract_server.rb:337:in `main\_loop’  
passenger (2.2.2) lib/phusion\_passenger/abstract\_server.rb:187:in  
`start_synchronously' passenger (2.2.2) lib/phusion_passenger/abstract_server.rb:154:in `start’  
passenger (2.2.2)  
lib/phusion\_passenger/railz/application\_spawner.rb:192:in `start' passenger (2.2.2) lib/phusion_passenger/spawn_manager.rb:257:in `spawn\_rails\_application’  
passenger (2.2.2)  
lib/phusion\_passenger/abstract\_server\_collection.rb:126:in  
`lookup_or_add' passenger (2.2.2) lib/phusion_passenger/spawn_manager.rb:251:in `spawn\_rails\_application’  
passenger (2.2.2)  
lib/phusion\_passenger/abstract\_server\_collection.rb:80:in `synchronize' passenger (2.2.2) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize’  
passenger (2.2.2) lib/phusion\_passenger/spawn\_manager.rb:250:in  
`spawn_rails_application' passenger (2.2.2) lib/phusion_passenger/spawn_manager.rb:153:in `spawn\_application’  
passenger (2.2.2) lib/phusion\_passenger/spawn\_manager.rb:282:in  
`handle_spawn_application' passenger (2.2.2) lib/phusion_passenger/abstract_server.rb:337:in ` **send** ’  
passenger (2.2.2) lib/phusion\_passenger/abstract\_server.rb:337:in  
`main_loop' passenger (2.2.2) lib/phusion_passenger/abstract_server.rb:187:in `start\_synchronously’

I’m at a loss as to how to fix this. Anyone?

Thanks!

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [May 31, 2009, 5:30pm UTC](https://www.ruby-forum.com/t/routing-error-with-passenger-for-images-and-stylesheets/169169/2 "2009-05-31T17:30:38Z")

</div>

John T. wrote:

> Hi,
> 
> I updated my server with the latest Rails (2.3.2) and Passenger (2.2.2).  
> I also updated my Rails app to run under 2.3.2. It runs  
> fine locally under Mongrel.
> 
> The app is deployed into my own home directory under: (deployed via  
> Capistrano)  
> /users/me/public\_html/myapp/current (which is a symlink to the  
> actual app)  
> and it’s accessed by the url:  
> [http://myserver.com/myapp](http://myserver.com/myapp)
> 
> I was getting routing errors, where Passenger/Apache could not find the  
> default route. But I found a post saying Passenger  
> has an issue with routing, so I added the RailsBaseURI to the  
> environment.rb file:

…

> Processing ApplicationController#index (for 1.2.3.4 at 2009-05-30  
> 13:11:46) [GET]
> 
> ActionController::RoutingError (No route matches  
> “/stylesheets/scaffold.css” with {:method=\>:get}):

Hate to bump my own post, but I really could use some input… nothing  
I’ve tried works.

Thanks.

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [May 31, 2009, 8:23pm UTC](https://www.ruby-forum.com/t/routing-error-with-passenger-for-images-and-stylesheets/169169/3 "2009-05-31T20:23:42Z")

</div>

On May 31, 2009, at 8:30 AM, John T. wrote:

> > /users/me/public\_html/myapp/current (which is a symlink to the  
> > …  
> > I’ve tried works.
> 
> ## Thanks.

You didn’t say what server you were using, but you need to point  
passenger to your _public_ directory, not RAILS\_ROOT as described  
here:  
[http://www.modrails.com/documentation/Users%20guide%20Apache.html#\_deploying\_to\_a\_virtual\_host\_8217\_s\_root](http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_to_a_virtual_host_8217_s_root)

The Apache VirtualHost section they use as an example is:

\<VirtualHost \*:80\>  
ServerName [www.mycook.com](http://www.mycook.com)  
DocumentRoot /weebapps/mycook/public

They have a section on nginx if that’s the server you are using.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [May 31, 2009, 8:47pm UTC](https://www.ruby-forum.com/t/routing-error-with-passenger-for-images-and-stylesheets/169169/4 "2009-05-31T20:47:44Z")

</div>

Steve R. wrote:

> You didn’t say what server you were using, but you need to point  
> passenger to your _public_ directory, not RAILS\_ROOT as described  
> here:  
> [Phusion Passenger users guide, Apache version](http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_to_a_virtual_host_8217_s_root)
> 
> The Apache VirtualHost section they use as an example is:
> 
> \<VirtualHost \*:80\>  
> ServerName [www.mycook.com](http://www.mycook.com)  
> DocumentRoot /weebapps/mycook/public
> 
> They have a section on nginx if that’s the server you are using.
> 
> Hope this helps.

Oh, yeah, thought the config file would make it obvious. It’s Apache  
with Passenger. And I am pointing to the public directory:

Directory "/home/me/public\_html/myapp/current/public

---

<div class="post-metadata">

**Author:** ![johnt519](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/cab0a1/32.png) [@johnt519](https://www.ruby-forum.com/u/johnt519)\
**Post date:** [June 1, 2009, 2:50pm UTC](https://www.ruby-forum.com/t/routing-error-with-passenger-for-images-and-stylesheets/169169/5 "2009-06-01T14:50:21Z")

</div>

John T. wrote:

> Oh, yeah, thought the config file would make it obvious. It’s Apache  
> with Passenger. And I am pointing to the public directory:
> 
> Directory "/home/me/public\_html/myapp/current/public

With thanks to Hongli L. over on the Phusion Passenger Google Group, I  
got this sorted out. And for completeness and to help others this is  
what I did.

I set up a new directory under /var/www:

/var/www/myapp

and created a symlink from there to my app’s public folder:

ln -s /home/me/public\_html/myapp/current/public myapp

and changed my apache vhost file to be:

\<VirtualHost \*:80\>  
ServerName [myserver.com](http://myserver.com)  
DocumentRoot /var/www/myapp  
\<Directory “/var/www/myapp”\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all  
  
RailsBaseURI /myapp

and made sure to include:

config.action\_controller.relative\_url\_root = ‘/myapp’

in my environment.rb file.

Hongli’s description:

> /var/www/myapp should be a directory. Inside this  
> directory there should be a ‘myapp’ symlink. Like this:

> /var/www/myapp/  
> /var/www/myapp/myapp → /home/me/public\_html/myapp/current/public

> When you say “RailsBaseURI /something”, then Phusion Passenger will  
> look for a filesystem entry “$DOCUMENT\_ROOT/something”, and this  
> _must_ be a symlink to the ‘public’ directory of your Rails app.

Hope this helps someone else!

jt
