# Routing failures

**URL:** <https://www.ruby-forum.com/t/routing-failures/68033>\
**Category:** Rails\
**Created:** [February 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/routing-failures/68033 "2006-02-14T15:13:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/routing-failures/68033/1 "2006-02-14T15:13:16Z")

</div>

probably something really simple but I don’t understand.

Shifting to Apache to w/ fastcgi (definitely feels faster than webrick)

Anyway, I set the default route in routes.rb to be

map.connect ‘’, :controller =\> “placements”, :action =\> ‘list’

which worked once I figured out apache…

Anyway, now that I have done that, all attempts to access stuff inside  
the public directory fails (stylesheets, javascripts etc.) with this in  
the logs…

ActionController::RoutingError (Recognition failed for  
“/stylesheets/case\_manager.css”):

(I don’t think I need to keep including more of these or the traces).

I would like to have it do the default route but if it breaks  
everything, that doesn’t make much sense…where am I going wrong?

Thanks

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/routing-failures/68033/2 "2006-02-14T15:13:17Z")

</div>

And it works if you go to /placements/list directly?

Do you have the html using relative paths?  
(…/…/stylesheets/case\_manager.css) or are you using the rails tags for  
stylesheets?

- Byron

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/routing-failures/68033/3 "2006-02-14T15:13:18Z")

</div>

On Tue, 2006-02-14 at 08:38 -0500, Byron S. wrote:

> And it works if you go to /placements/list directly?

* * *

## No change in behavior

> Do you have the html using relative paths?

* * *

yes - all of the calls are in my ‘layouts’ and they are simply like…

## \<%= stylesheet\_call\_tag ‘placements’ %\>

> (…/…/stylesheets/case\_manager.css) or are you using the rails tags  
> for stylesheets?
> 
> - Byron

* * *

## Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2006, 3:13pm UTC](https://www.ruby-forum.com/t/routing-failures/68033/4 "2006-02-14T15:13:19Z")

</div>

On Tue, 2006-02-14 at 06:54 -0700, Craig W. wrote:

> \<%= stylesheet\_call\_tag ‘placements’ %\>

* * *

## need coffee - need coffee \<%= stylesheet\_link\_tag ‘placements’ %\>

> * * *
> 
> > (…/…/stylesheets/case\_manager.css) or are you using the rails tags  
> > for stylesheets?
> > 
> > - Byron

* * *

FWIW - webrick still works fine so this problem is peculiar to my setup  
with apache/fastcgi

## Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2006, 4:03pm UTC](https://www.ruby-forum.com/t/routing-failures/68033/5 "2006-02-14T16:03:56Z")

</div>

OK - one more time with clarity points added…

probably something really simple but I don’t understand.

Shifting to Apache to w/ fastcgi (definitely feels faster than webrick)

Anyway, I set the default route in routes.rb to be

map.connect ‘’, :controller =\> “placements”, :action =\> ‘list’

which worked once I figured out apache…

Anyway, now that I have done that, all attempts to access stuff inside  
the public directory fails (stylesheets, javascripts etc.) with this in  
the logs…

ActionController::RoutingError (Recognition failed for  
“/stylesheets/case\_manager.css”):

(I don’t think I need to keep including more of these or the traces).

I would like to have it do the default route but if it breaks  
everything, that doesn’t make much sense…where am I going wrong?

- running webrick… connections to baseurl work fine…  
i.e. [http://localhost:3000](http://localhost:3000)

- references to javascripts and stylesheets are all the ‘ruby’ way…  
i.e \<%= stylesheet\_link\_tag ‘placements’ %\>  
\<%= javascript\_include\_tag "defaults %\>

I thought I followed all the instructions and apache and fastcgi seem to  
be doing their part.

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2006, 4:22pm UTC](https://www.ruby-forum.com/t/routing-failures/68033/6 "2006-02-14T16:22:48Z")

</div>

Craig W. wrote:

> OK - one more time with clarity points added…
> 
> probably something really simple but I don’t understand.
> 
> Shifting to Apache to w/ fastcgi (definitely feels faster than webrick)
> 
> Anyway, I set the default route in routes.rb to be
> 
> map.connect ‘’, :controller =\> “placements”, :action =\> ‘list’
> 
> which worked once I figured out apache…
> 
> Anyway, now that I have done that, all attempts to access stuff inside  
> the public directory fails (stylesheets, javascripts etc.) with this in  
> the logs…

It sounds more like .htaccess problem, since a request for a static file  
is being passed to rails for routing, it’s somehow being skipped by the  
.htaccess rules.

Here’s the relevant section from a random rails app on my HD (not sure  
how old it is, but it’s the default, unchanged, .htaccess)

# 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  
RewriteRule ^$ index.html [QSA]  
RewriteRule ^([^.]+)$ $1.html [QSA]  
RewriteCond %{REQUEST\_FILENAME} !-f  
RewriteRule ^(.\*)$ dispatch.cgi [QSA,L]

You’ll have changed that last line to be fcgi, but all the others should  
be unchanged… are they ?

Random aside, are you using Windows ?

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 14, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/routing-failures/68033/7 "2006-02-14T19:27:41Z")

</div>

On Tue, 2006-02-14 at 16:22 +0100, Alan F. wrote:

> > 
> 
> Here’s the relevant section from a random rails app on my HD (not sure  
> RewriteRule ^$ index.html [QSA]  
> RewriteRule ^([^.]+)$ $1.html [QSA]  
> RewriteCond %{REQUEST\_FILENAME} !-f  
> RewriteRule ^(.\*)$ dispatch.cgi [QSA,L]
> 
> You’ll have changed that last line to be fcgi, but all the others should  
> be unchanged… are they ?
> 
> Random aside, are you using Windows ?

* * *

No - not Windows, CentOS 4 (Linux)

I had uncommented this line…

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

as I am certain that one of the instruction pages had told me to  
uncomment it…and of course, commenting it out once again and  
restarting apache seems to have fixed it.

Thanks

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 15, 2006, 6:01pm UTC](https://www.ruby-forum.com/t/routing-failures/68033/8 "2006-02-15T18:01:42Z")

</div>

On Wed, 2006-02-15 at 11:13 +0100, Alan F. wrote:

> Hi Craig,
> 
> Does that make sense ?
> 
> I’m suspecting that the dispatch line must be last (whether or not it’s  
> for cgi or fcgi)

* * *

Gotcha - it worked

Thanks a lot…

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [February 15, 2006, 11:13am UTC](https://www.ruby-forum.com/t/routing-failures/68033/9 "2006-02-15T11:13:27Z")

</div>

Craig W. wrote:

> I had uncommented this line…
> 
> # RewriteRule ^(.\*)$ dispatch.fcgi [QSA,L]
> 
> as I am certain that one of the instruction pages had told me to  
> uncomment it…and of course, commenting it out once again and  
> restarting apache seems to have fixed it.

Hi Craig,

By commenting back out again, you’re using cgi for Rails instead of  
fcgi. If you want fastcgi instead of cgi, instead of uncommenting that  
line, change that last rule in the block from dispatch.cgi to  
dispatch.fcgi.

I suspect there must be an order dependency and by cuncommenting the  
line above the rest of the rules, you route EVERYTHING to the FCGI  
instead of passing through the index.html / \*.html / filesystem rules  
before finally routing to rails.

Does that make sense ?

I’m suspecting that the dispatch line must be last (whether or not it’s  
for cgi or fcgi)

A.
