You can put those methods in a module:
module WidgetBehavior
def dosomething
...
end
end
class User
has_many :widgets, :extend => WidgetBehavior
end
With code like this, you get:
u = User.new
u.widgets.dosomething
You can also do this, if you want the same behavior on the Widget
class directly:
class Widget
extend WidgetBehavior
end
Widget.dosomething
This last bit won't give you the behavior on the association, however.
It's an optional add-on to the has_many :extend code.
It doesn't save you from having widget-related code in two places, but
at least the two places are reasonably named. Having widget code in
the User model makes me cringe just a little. :)
=======================================================
Brent Miller
Owner and Principal
Foliosus Web Design LLC
http://foliosus.com/