gpt4 book ai didi

ruby-on-rails-5 - Assets 未声明为在生产中预编译(Rails 5.0.0.1)

转载 作者:行者123 更新时间:2023-12-04 23:39:58 24 4
gpt4 key购买 nike

我是新来的 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.


我生成了一些脚手架(也生成了 Assets —— .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



我按照它说的做了,它起作用了,但是在那里 任何其他简化此过程的方法 ?
我希望我可以用它们的 Assets 生成一些其他的脚手架或 Controller ,而不必再担心在 config/initializers/assets.rb 中添加新行。 .
我也会收到任何其他选择。

最佳答案

你试试这个..

检查您的 Gemfile gem 'sprockets-rails', '2.3.3'
bundle install

关于ruby-on-rails-5 - Assets 未声明为在生产中预编译(Rails 5.0.0.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40946663/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com