Created
August 25, 2017 05:28
Star
You must be signed in to star a gist
Rails : Server separate images in production and development environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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