mardi 22 septembre 2015

Rails.application.routes.url_helpers missing method

I've read here Can Rails Routing Helpers (i.e. mymodel_path(model)) be Used in Models? how to include the url helpers in my model. However, when I try to run Rails.application.routes.url_helpers.products_path from within my models, I get a NoMethodError: undefined method products_path for #<Module:0x007fea1d4ffa38>.

The same thing happens, when I try it within a view:

<%= products_path %> # generates /products
<%= Rails.application.routes.url_helpers.products_path %> # raises a NoMethodError

Any idea, why this is happening? I'm on Rails 3.2.9

Aucun commentaire:

Enregistrer un commentaire