How to use polymorphic_path in lib/module in Rails 4 -
i want call polymorphic_path in helper module located @ lib/my_module.rb
.
i tried following this answer, works in model, not in 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' mymodule:module
btw, load module through config.autoload_paths += %w(#{config.root}/lib)
in config/application.rb
.
Comments
Post a Comment