Skip to content

Instantly share code, notes, and snippets.

@shivabhusal
Created August 25, 2017 05:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save shivabhusal/6ab10e74e03b43d98d57f3ecaa0e8006 to your computer and use it in GitHub Desktop.
Rails : Server separate images in production and development environment
module ApplicationHelper
# It hijacks the methods
[:image_tag, :image_path, :image_url].each do |m_name|
define_method(m_name) do |*arg|
begin
super(*arg)
rescue Sprockets::Rails::Helper::AssetNotFound
arg[0] = "#{Rails.env}/#{arg[0]}"
super(*arg)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment