Given I've defined this in the config/routes.rb
resource :products
If I want to access the route helpers such as product_path(self)
to generate urls in the Model. How could I mixin those modules in ?
Given I've defined this in the config/routes.rb
resource :products
If I want to access the route helpers such as product_path(self)
to generate urls in the Model. How could I mixin those modules in ?
class MyClass < ActiveRecord::Base
include Rails.application.routes.url_helpers
end
or (without inclusion)
Rails.application.routes.url_helpers.product_path(self)