开发者

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

开发者 https://www.devze.com 2023-03-13 15:59 出处:网络
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

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


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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号