资产未声明为在生产中预编译(Rails 5.0.0.1)
Asset was not declared to be precompiled in production (Rails 5.0.0.1)
我是 Rails 5.0.0.1
的新手
我遵循了 http://guides.rubyonrails.org/asset_pipeline.html#controller-specific-assets 中的指南:
You can also opt to include controller specific stylesheets and JavaScript files only in their respective controllers using the following:
<%= javascript_include_tag params[:controller] %>
or <%= stylesheet_link_tag params[:controller] %>
When doing this, ensure you are not using the require_tree directive, as that will result in your assets being included more than once.
我生成了一些脚手架(也生成了资产 -- .coffee
和 .scss
)
当我执行 rails s
并访问脚手架的主页之一时,它生成了一个错误:
Asset was not declared to be precompiled in production.
Add Rails.application.config.assets.precompile += %w( myscaffold.css )
to config/initializers/assets.rb
and restart your server
我按照它说的做了,而且有效,但是有没有其他方法可以简化这个过程?
我希望我可以用它们的资产生成一些其他脚手架或控制器,而不必再担心在 config/initializers/assets.rb
.
中添加新行
我也会收到任何其他替代品。
你试试这个..
检查你的Gemfile
gem 'sprockets-rails', '2.3.3'
和bundle install
浏览文件
config/initializers/assets.rb
然后添加
Rails.application.config.assets.precompile += %w( your_file_name.scss )
重启服务器
我是 Rails 5.0.0.1
我遵循了 http://guides.rubyonrails.org/asset_pipeline.html#controller-specific-assets 中的指南:
You can also opt to include controller specific stylesheets and JavaScript files only in their respective controllers using the following:
<%= javascript_include_tag params[:controller] %>
or<%= stylesheet_link_tag params[:controller] %>
When doing this, ensure you are not using the require_tree directive, as that will result in your assets being included more than once.
我生成了一些脚手架(也生成了资产 -- .coffee
和 .scss
)
当我执行 rails s
并访问脚手架的主页之一时,它生成了一个错误:
Asset was not declared to be precompiled in production.
Add
Rails.application.config.assets.precompile += %w( myscaffold.css )
toconfig/initializers/assets.rb
and restart your server
我按照它说的做了,而且有效,但是有没有其他方法可以简化这个过程?
我希望我可以用它们的资产生成一些其他脚手架或控制器,而不必再担心在 config/initializers/assets.rb
.
我也会收到任何其他替代品。
你试试这个..
检查你的Gemfile
gem 'sprockets-rails', '2.3.3'
和bundle install
浏览文件
config/initializers/assets.rb
然后添加
Rails.application.config.assets.precompile += %w( your_file_name.scss )
重启服务器