Ruby On Rails : Action Mailer : Get absolute path of assets (Env ; Development / Production)

You may want to set your app’s domain to something so that it makes easy for you to generate Absolute path for your APIs and assets in any environment.



# Set ENV['HOST'] = 'your_asset_host.com'
# For heroku : Its set by default
# in  config/production.rb
config.action_controller.asset_host = ENV['HOST']
config.action_mailer.asset_host = ENV['HOST']

# and you can get asset's absolute path by 
# in views/mailers
asset_path('logo.png') # -> your_asset_host.com/assets/logo.png.13123131422'

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s