简体   繁体   English

Ruby on Rails在资产中寻找css而不是公共/样式表

[英]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 我是Ruby新手,使用ruby 1.9.2P180和Rails 3.1.0.rc2

I have "screen.css" in my_app_root/public/stylesheets/screen.css and in my application.html.erb 我在my_app_root / public / stylesheets / screen.css和我的application.html.erb中有“screen.css”

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

according to here it should work but my rails server says: 根据这里它应该工作,但我的rails服务器说:

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) 由PagesController#home作为HTML处理在布局/应用程序内呈现页面/ home.html.erb(0.0ms)在4ms内完成200 OK(视图: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) 在2011-06-18 11:27:53开始GET“/assets/screen.css”为127.0.0.1 +1200服务资产/screen.css - 404未找到(2ms)(pid 10966)

ActionController::RoutingError (No route matches [GET] "/assets/screen.css"): ActionController :: RoutingError(没有路由匹配[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. 没什么,你只是使用默认的3.1安装,它使用新的基于sprockets的资产管道。

put your stylesheets into /app/assets/stylesheets and use 将您的样式表放入/ app / assets / stylesheets并使用

<%= 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 或者,您可以在application.rb中设置关闭新pipline

config.assets.enabled = false

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Ruby on Rails应用程序/资产/样式表的更改不会更改public / assets / application.css - Ruby on Rails app/assets/stylesheets changes don't change public/assets/application.css Rails:在'assets'和'public'下放置样式表之间的区别 - Rails: difference between placing stylesheets under 'assets' vs. 'public' Rails资产没有预编译,css在生产中看起来不同 - Rails assets not precompiling, css looks different in production Ruby on Rails-/ stylesheet目录中的样式表而不是/ assets中的样式表,生产中没有指纹 - Ruby on Rails - Stylesheets in /stylesheet directory and not in /assets, no fingerprint in production Rails资产控制器服务于公共资产,而不是资产的索引页面 - Rails assets controller serves public assets instead of assets' index page 我如何配置资产:预编译以在public / javascript或/ public / stylesheets中创建文件 - rails how do i configure assets:precompile for creating files inside public/javascript or /public/stylesheets Rails在开发模式下从公共/样式表而不是应用程序/资产加载CSS文件 - Rails loads css files from public/stylesheet instead of app/assets in development mode 公共Rails 2.3下样式表下Css文件中的图像URL - Image url in Css file under stylesheets under public Rails 2.3 Ruby on Rails条件样式表 - Ruby on Rails conditional stylesheets Ruby on Rails CSS资产管道组织问题 - Ruby on Rails css assets pipeline organization issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM