Topic: Production server problem URGENT

I'm struggling to prep a website for deployment, and when I start the server in the production environment it doesn't appear to be reading my css files.

I've got as far as realizing this is because in production (but for some reason, not in development) it's calling the stylesheet via a url. This is being caught by my custom routes and showing this message:

Started GET "/stylesheets/main.css?1286806926" for at Tue Oct 12 13:45:17 +0100 2010
  Processing by PageController#show as CSS
  Parameters: {"section"=>"stylesheets", "page"=>"main", "1286806926"=>nil}

I'm fairly sure it's because my custom routes are catching the stylesheet request. it'll be this line in routes.rb

match '/:section/:page' => 'page#show'

I've tried catching it with a line like:

match '/stylesheets/main.css' => "/public/stylesheets/main.css"
match '/stylesheets/main.css' => "/stylesheets/main.css"
match '/stylesheets' => "/public/stylesheets"

None of this works, I can point it at a different method, but not at an actual file in the public directory.

This is rather urgent and I'm a bit stuck with it.



Last edited by AJFaraday (2010-10-12 09:01:31)

Re: Production server problem URGENT

Oh, removing the offending match line still doesn't point towards the css file. I get this error

Started GET "/stylesheets/main.css?1286806926" for at Tue Oct 12 14:08:56 +0100 2010

ActionController::RoutingError (No route matches "/stylesheets/main.css"):

This shouldn't be happening, should it?

Re: Production server problem URGENT

move match '/:section/:page' => 'page#show' to the very last route in your routes.rb and scrap the
match '/stylesheets/main.css' => "/public/stylesheets/main.css"
match '/stylesheets/main.css' => "/stylesheets/main.css"
match '/stylesheets' => "/public/stylesheets"

If you got this issue sorted then forget it but otherwise can you post your stylesheet link tag declaration

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Production server problem URGENT

The Actual problem was that for some reason in Rails 3, config/environments/production.rb has a line which declares..

serve static resources => false

Which means that there was no access to the /public folder. The stylesheet tag was the same as ever...

- stylesheet_link_tag :all