Rails.application.config.assets.paths Rails.application.config.assets.precompile
の2つの設定があるのですがそれぞれ何を意味してるんでしょうか
assets に common/common.scss という SCSS ファイルを追加したところ
ActionView::Template::Error (Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( common/common.css )` to `config/initializers/assets.rb` and restart your server):
といわれたので
Rails.application.config.assets.precompile += %w( *.css *.scss *.js )
と追加したんですが
# RAILS_ENV=staging bundle exec rake assets:precompile assets:clean rake aborted! Sass::SyntaxError: Undefined variable: "$navbar-height".
と gem の中でよくわからないエラーが出ます
エラーを検索すると *.css というワイルドカードが悪いみたいなんですが
assets にファイルを追加するたびに initializer にも同じファイル名を追加する必要があるのでしょうか?
追記:
Rails ガイド
https://railsguides.jp/asset_pipeline.html#アセットをプリコンパイルする
にある
以下のようにすべてのアセットをプリコンパイルすることもできます。
Rails.application.config.assets.precompile << Proc.new do |path| if path =~ /.(css|js)\z/ full_path = Rails.application.assets.resolve(path).to_path app_assets_path = Rails.root.join('app', 'assets').to_path if full_path.starts_with? app_assets_path logger.info "including asset: " + full_path true else logger.info "excluding asset: " + full_path false end else false end end
を試しにかいてみたんですが
full_path = Rails.application.assets.resolve(path).to_path
のところで
undefined method `to_path' for #<String:0x007f10669a8a30>
とエラーになって動きません
あなたの回答
tips
プレビュー