ruby on rails - RoR: How to use *_path in a model? -


I need to generate a "report" in a model. I have to include a link in this "report", however, all * _path functions are not available in model classes (a simple test shows me that new_post_path raises an exception in my model but works fine in my controllers)

What is the method to use Polymorphic_url Or, at least, * _path methods in my models?

If you are:

  contains ActionController :: PolymorphicRoutes  

In your model:

  class SomeModel & lt; You receive  polymorphic_path  and  polymorphic_url  in ActionController :: PolymorphicRoutes closing  

in ActiveRecord :: Base. If you are preparing a route for the current AR object then it can be used to pass self in these methods.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -