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'] = ''
# 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') # ->'



Leave a Reply

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

You are commenting using your 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