Re: [Rails] Create a helper for models and views?

2013-02-04 Thread tamouse mailing lists
On Sun, Feb 3, 2013 at 8:36 AM, Johnneylee Rollins johnneylee.roll...@gmail.com wrote: Additionally, you can put it inside its own class and use that as necessary. It'd be similar to the previous answer, but instead of including that behaviour, you'd get an instance of that class and pass in

[Rails] Create a helper for models and views?

2013-02-03 Thread Linus Pettersson
Hi! If I have a method that is useful in both models and in views, where would be the appropriate place to put it? The method in question just takes two dates as strings, tries to parse them and returns all dates in the range between them. It also takes care of the issues when the dates are

Re: [Rails] Create a helper for models and views?

2013-02-03 Thread Jordon Bedwell
On Sun, Feb 3, 2013 at 6:23 AM, Linus Pettersson linus.petters...@gmail.com wrote: If I have a method that is useful in both models and in views, where would be the appropriate place to put it? # config/initializer/preload_helpers.rb require my_app/my_helper # lib/my_app/my_helper.rb -

Re: [Rails] Create a helper for models and views?

2013-02-03 Thread Johnneylee Rollins
Additionally, you can put it inside its own class and use that as necessary. It'd be similar to the previous answer, but instead of including that behaviour, you'd get an instance of that class and pass in the strings either in #initialize or the method you use to parse and call that method.