asset_url in mailer on rails 3.1

后端 未结 1 1853
无人及你
无人及你 2020-12-30 10:30

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(\"#{Rai         


        
相关标签:
1条回答
  • 2020-12-30 10:57

    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.

    0 讨论(0)
提交回复
热议问题