I put my class-wide functions in app/helpers/global_helpers.rb which make use of the module/include mechanisms for you.
On Apr 22, 11:23 am, Eleo <[email protected]> wrote: > You could put the module in your models directory if you don't want to > have to require it like that. > > It seems like Merb.root/lib/ gets loaded after models. I was having > this problem a few days ago. > > On Apr 21, 4:50 pm, tenstates <[email protected]> wrote: > > > > > > > Ok, I had tried this but without luck. I added the lib directory to > > the init.rb > > > Merb.push_path(:lib, Merb.root / "lib") > > > to make sure but this didn't help when loading the module. So, I had > > to go for this but it is a bit messy. > > > class ModelClass > > require Merb.root / 'lib' / 'modelhelpers' > > include ModelHelpers > > end > > > On Apr 22, 3:47 am, Jonathan Stott <[email protected]> wrote: > > > > On Wed, 21 Apr 2010 12:39:41 -0700 (PDT) > > > > tenstates <[email protected]> wrote: > > > > > This has been bugging me but how best do I share a bunch of methods > > > > across multiple models? > > > > modules. Which is standard ruby. > > > > module DescriptiveName > > > def useful_method > > > # ... > > > end > > > > def another_useful_method > > > end > > > end > > > > class ModelClass > > > include DescriptiveName > > > end > > > > Or if you want class methods, extend! > > > > Regards > > > Jon > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "merb" group. > > > To post to this group, send email to [email protected]. > > > To unsubscribe from this group, send email to > > > [email protected]. > > > For more options, visit this group > > > athttp://groups.google.com/group/merb?hl=en. > > > -- > > You received this message because you are subscribed to the Google Groups > > "merb" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group > > athttp://groups.google.com/group/merb?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "merb" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/merb?hl=en. -- You received this message because you are subscribed to the Google Groups "merb" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/merb?hl=en.
