In my Rails 5 app, I'm trying to get the full URL for my instance, but when I tried to use url_for
as suggested in this SO question, I get an error, NoMethodError: undefined method 'url_for' for #<Product:0x8646fc0>
.
Full URL with url_for in Rails
def get_url
url = url_for(self)
end
I also tried product_url(self)
and received a similar error.
What's the proper way to get the URL for my instance? Thanks!