ruby on rails - If I have a function that I use both in the controller and in the views, where should I put it? -


I try to be very good about keeping my visual code and my controller code apart, but sometimes I go into situations where I need to use the same function in the controller and ideas where should I put this function so that I can get it from both controller and view?

You can put it in the controller and make it available as a helper. If you need to be available among the controllers and their controllers or other controllers placed in heritage:

  helper_method: shared_function  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -