I'm writing rails 4 application and I'm trying to refactor assets.rb file.
Currect state:
Rails.application.config.assets.enabled = true
Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.prefix = '/sprockets'
Rails.application.config.assets.precompile += %w(404.html 500.html)
Rails.application.config.assets.precompile << %w( big array of css files)
Rails.application.config.assets.precompile << %w( big array of js files)
What I want to see:
Rails.application.config.assets do |assets|
assets.enabled = true
assets.version = '1.0'
assets.prefix = '/sprockets'
assets.paths << "#{Rails.root}/app/assets/plugins"
assets.paths << "#{Rails.root}/app/assets/html"
assets.precompile += %w(404.html 500.html)
assets.precompile << /\.(?:svg|eot|woff|ttf|swf)\z/
# css
assets.precompile << %w( big array of css files)
# js
assets.precompile << %w( big array of js files)
end
Is it possible to pass a block of code into Rails.application.config.assets
?
Not possible because assets doesn't expect s block if you look at its signature. You can pass it, but it won't have any effect on assets.