[Rails] Re: helper for model?

2009-01-18 Thread Pardee, Roy
Abbott Sent: Friday, January 16, 2009 9:16 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: helper for model? Yes. In your module you've defined an instance method not a class method. But this: class CarePhase ActiveRecord::Base include ModelHelper pretend_helper(hi

[Rails] Re: helper for model?

2009-01-16 Thread Pardee, Roy
-t...@googlegroups.com] On Behalf Of Joshua Abbott Sent: Wednesday, January 14, 2009 9:18 PM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: helper for model? I just posted a similar question regarding best practices when you have methods you want to share across multiple AR models. I

[Rails] Re: helper for model?

2009-01-16 Thread Joshua Abbott
Yes. In your module you've defined an instance method not a class method. But this: class CarePhase ActiveRecord::Base include ModelHelper pretend_helper(hi!) Is the class trying to call the method, which fails because the class doesn't know about the 'pretend_helper' method.

[Rails] Re: helper for model?

2009-01-15 Thread Ar Chron
Another option is to inject an abstract class model between AR and the rest of your models. some class GenericModel ActiveRecord where GenericModel implements all manner of standard infrastructure functionality that is written once. Very easy for a specific model to override default

[Rails] Re: helper for model?

2009-01-14 Thread Brandon Keepers
On Wed, Jan 14, 2009 at 8:26 PM, Pardee, Roy parde...@ghc.org wrote: Hey All, I find I'm writing a ton of nearly identical model methods to support mass creation/update of child objects (a la the 'complex forms' series of railscasts). Stuff like: def

[Rails] Re: helper for model?

2009-01-14 Thread Joshua Abbott
I just posted a similar question regarding best practices when you have methods you want to share across multiple AR models. I ended up writing a module and sticking it in the lib directory. In order to make these methods available to your models, simply include it with: class Post