Bundler.require(*Rails.groups(:assets => %w(development test)))
from config/application.rb, i.e.
# If you precompile assets before deploying to production, use this line
Bundler.require *Rails.groups(:assets => %w(development test))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
…can look a bit hairy if you’re new to Ruby / Rails.
Breaking it down:
1. The splat operator (*) breaks out the array.
[:default, “development”] => nil
2.0.0p195 :006 > print *Rails.groups
defaultdevelopment => nil
More on the splat operator here:
2. The %w defines an array
is shorthand for an array of strings like this:
Note that: %w is slightly different from %W
3. The colon operator (i.e. :assets) is a symbol
:assets => (“development”, “test”)
Symbols are different from strings in that any two symbols named the same are identical:
“foo”.equal? “foo” # false
:foo.equal? :foo # true
More on how the assets group is handled here:
and more on the Rails/Bundler precompile vs lazy compile here: