actionmailer - Rails - URL helpers not working in mailers -
i tried:
class mymailer def routes rails.application.routes.url_helpers end def my_mail @my_route = routes.my_helper ... code omitted end
also inside mailer:
include rails.application.routes.url_helpers def my_mail @my_route = my_helper
also, simple way, in mailer template:
= link_to 'asd', my_helper
but when try start console get:
undefined method `my_helper' #<module:0x007f9252e39b80> (nomethoderror)
update
i using _url
form of helper, i.e. my_helper_url
for rails 5, included url helpers mailer file:
# mailers/invoice_mailer.rb include rails.application.routes.url_helpers class invoicemailer < applicationmailer def send_mail(invoice) @invoice = invoice mail(to: @invoice.client.email, subject: "invoice test") end end
Comments
Post a Comment