How can I access the polymorphic path inside the model in Rails 4?

Pretty simple, I want to use the polymorphic_path method inside the Rails 4 model. Yes, I know this is a bad separation of problems. And I know about Rails.application.routes.url_helpers , but the polymorphic_path is not there.

+6
source share
1 answer

Try including PolymorphicRoutes as well:

 include ActionDispatch::Routing::PolymorphicRoutes include Rails.application.routes.url_helpers def link polymorphic_path(self) end 
+7
source

Source: https://habr.com/ru/post/978352/


All Articles