Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails looks for css in assets instead of public/stylesheets

I am new to Ruby, using ruby 1.9.2P180 and Rails 3.1.0.rc2

I have "screen.css" in my_app_root/public/stylesheets/screen.css and in my application.html.erb

 <%= stylesheet_link_tag 'screen.css', :media => 'screen' %>

according to here it should work but my rails server says:

Processing by PagesController#home as HTML Rendered pages/home.html.erb within layouts/application (0.0ms) Completed 200 OK in 4ms (Views: 3.6ms | ActiveRecord: 0.0ms)

Started GET "/assets/screen.css" for 127.0.0.1 at 2011-06-18 11:27:53 +1200 Served asset /screen.css - 404 Not Found (2ms) (pid 10966)

ActionController::RoutingError (No route matches [GET] "/assets/screen.css"):

What am I doing wrong here?

Thanks in advance

like image 562
Yuan Avatar asked Jun 17 '11 23:06

Yuan


1 Answers

What am I doing wrong here?

Nothing, you are just using a default 3.1 install which uses the new sprockets-based asset pipeline.

put your stylesheets into /app/assets/stylesheets and use

<%= stylesheet_link_tag 'application.css' %> 

in your views

the new pipeline takes all the stylesheets in that folder and automagically compiles them into a single file.

==

Alternatively, you can set turn the new pipline off in your application.rb with

config.assets.enabled = false
like image 134
colinross Avatar answered Sep 30 '22 22:09

colinross