I want to call polymorphic_path in a helper module located at lib/my_module.rb
.
I tried the following from this answer, which works in a model, but not in my module:
module MyModule
include ActionDispatch::Routing::PolymorphicRoutes
include Rails.application.routes.url_helpers
def link(model)
polymorphic_path(model)
end
end
I get:
undefined method `polymorphic_path' for MyModule:Module
Btw, I load my module through config.autoload_paths += %W(#{config.root}/lib)
in config/application.rb
.