Rails 3.1:无法在应用程序中启用资产管道
我有 3.1 应用程序。 一开始我添加了 config.assets.enabled = false
不使用管道。
现在我已经评论了这一行。重新启动服务器。
app\assets\javascripts\application.js
我在我的布局视图中使用了 : <%= javascript_include_tag "application" %>
我的页面尝试加载 "javascripts/application.js" 而不是 asset/application.js
我的配置可能有问题?
gemfile(不必要的删除):
gem 'rails', '3.1.1'
gem 'sqlite3'
# Asset template engines
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
I've got 3.1 application.
At the beginning i'd addedconfig.assets.enabled = false
not to use pipeline.
Now i've commented this line. restart server.
I've got app\assets\javascripts\application.js
In my layout view I use:<%= javascript_include_tag "application" %>
my page tries to load "javascripts/application.js" not assets/application.js
What may be wrong in my configuration?
gemfile (unnecessary removed):
gem 'rails', '3.1.1'
gem 'sqlite3'
# Asset template engines
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过将其保留并使其
config.assets.enabled = true
而不是注释掉该行?看起来默认值总是false
,因此您需要显式地将其设置为true
。Rather than commenting out the line, have you tried leaving it in and making it
config.assets.enabled = true
instead? It looks like the default value will always befalse
, so you need to explicitly set it totrue
.如果关闭管道,Rails 帮助程序将恢复到 javascript 和 CSS 的旧路径 - 在 /public 目录中的这些文件夹中。如果您不想使用管道,那么您必须使用这些文件夹,而不是资产文件夹。
Dylan 是正确的 - 您必须显式启用管道,这是新生成的应用程序的默认设置。
If you turn the pipeline off then the Rails helpers revert to the old paths to javascript and CSS - in those folders in the /public directory. If you don't want to use the pipeline then you have to use those folders instead, not the assets folder ones.
Dylan is correct - you have to explicitly enable the pipeline, and this is the default for a new generated app.