How to get url_for an object in a model method in Rails

I would like to create a string containing the path for an object in Rails.

def notification_content "#{app.listing_url(my_listing, :host => "example.com")}. " + end 

This content will be transferred to my ActionMailer as email content.

It works great in the console. However, when I run it on the local server, I get the following error:

 undefined local variable or method `app' 

How can I do it? Also, how can I make the path a hyperlink?

Many thanks.

+8
url ruby-on-rails actionmailer
source share
1 answer
 include Rails.application.routes.url_helpers def notification_content "#{listing_url(my_listing, :host => "example.com")}. " + ... end 
+15
source share

All Articles