Forum: Ruby on Rails routing failures

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Craig W. (Guest)
on 2006-02-14 16:13
(Received via mailing list)
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
Byron S. (Guest)
on 2006-02-14 16:13
(Received via mailing list)
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
Craig W. (Guest)
on 2006-02-14 16:13
(Received via mailing list)
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
----
Craig W. (Guest)
on 2006-02-14 16:13
(Received via mailing list)
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
----
Craig W. (Guest)
on 2006-02-14 17:03
(Received via mailing list)
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

- 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
Alan F. (Guest)
on 2006-02-14 17:22
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 ?
Craig W. (Guest)
on 2006-02-14 20:27
(Received via mailing list)
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
Alan F. (Guest)
on 2006-02-15 12:13
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.
Craig W. (Guest)
on 2006-02-15 19:01
(Received via mailing list)
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
This topic is locked and can not be replied to.