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
-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
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.
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
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
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
6 matches
Mail list logo