Created
August 25, 2017 05:28
-
-
Save shivabhusal/6ab10e74e03b43d98d57f3ecaa0e8006 to your computer and use it in GitHub Desktop.
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