Skip to content

Instantly share code, notes, and snippets.

@fny
Created July 8, 2015 01:09
Show Gist options
  • Save fny/7ab53d4537e848075d01 to your computer and use it in GitHub Desktop.
Save fny/7ab53d4537e848075d01 to your computer and use it in GitHub Desktop.
Dry Up Your Initializers with #tap
# Before
Rails.application.config.assets.version = '1.0'
Rails.application.config.assets.paths << Emoji.images_path
Rails.application.config.assets.precompile += %w( search.js )
# After
Rails.application.config.assets.tap do |assets|
assets.version = '1.0'
assets.paths << Emoji.images_path
assets.precompile += %w( search.js )
end
Copy link

ghost commented Jul 13, 2015

As alternative you can use instance_eval here:

Rails.application.config.assets.instance_eval do
  # 'self' here is your assets config
  self.version = '1.0'
  self.paths << Emoji.images_path
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment