I have my mailer on rails 3.1 which has an inline attachment.
To open that attachment i use this code:
attachments["rails.png"] = File.read("#{Rails.root}/app/assets/images/Rails.png")
is there a way to change that with something like assets_url
?
If I understand correctly, you want to use the asset pipeline's search functionality to locate the local path for a given asset so you don't have to hard-code which directory it's in. If that's the case, you want to do this:
<YourAppName>::Application.assets.find_asset('Rails.png').pathname
This will locate the asset using standard pipeline/sprockets searching, and give you the fully qualified local path to the file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With