In assets.rb, I am using following code
def javascript_manifest_files(loc = '')
Dir.chdir("#{Rails.root}/app/assets/javascripts/") do
Dir["#{loc}*.js"]
end
end
def stylesheet_manifest_files(loc = '')
Dir.chdir("#{Rails.root}/app/assets/stylesheets/") do
Dir["#{loc}*.css"]
end
end
['', 'web/'].each do |loc|
Rails.application.config.assets.precompile += javascript_manifest_files(loc) + stylesheet_manifest_files(loc)
end
I am very new to rails, found this solution for assets pipelining to work.
For JS I am getting all the required javascritp but for stylesheets I am not getting the styles.
To call the stylesheets I am using this command
<%= stylesheet_link_tag 'application', media: 'all' %>
<%= stylesheet_link_tag "#{params[:controller]}", media: 'all' %>
When I am trying to open that page, geting following error. Someone please help me out to solve this issue.
Sprockets::Rails::Helper::AssetFilteredError at / Asset filtered out and will not be served: add `Rails.application.config.assets.precompile += %w( web/home_page.css
)
to
config/initializers/assets.rb` and restart your server
Aucun commentaire:
Enregistrer un commentaire