Single quote string string interpolation

后端 未结 3 943
借酒劲吻你
借酒劲吻你 2021-01-12 20:18

I am trying to set an email address within ActionMailer with Rails. Before it was hard coded, but we want to make them ENV variables now so we don\'t need to amend code each

3条回答
  •  粉色の甜心
    2021-01-12 20:46

    If you want to embed double quotes in an interpolated string you can use % notation delimiters (which Ruby stole from Perl), e.g.

    from = %|"Name of Person", <#{ENV['EMAIL']}>|
    

    or

    from = %("Name of Person", <#{ENV['EMAIL']}>)
    

    Just pick a delimiter after the % that isn't already in your string.

提交回复
热议问题