Reputation: 9298
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 ?
Upvotes: 0
Views: 825
Reputation: 12818
class MyClass < ActiveRecord::Base
include Rails.application.routes.url_helpers
end
or (without inclusion)
Rails.application.routes.url_helpers.product_path(self)
Upvotes: 3