Extract Class and Rails model objects

Do you ever break up a large rails model class into smaller classes for
the
sake of just having smaller classes?

I have a user model class that is growing in number of attributes quite
quickly. A part of me thinks I should group attributes together and
peel
them off as separate classes in order to reduce the number of attributes
in
the user class, another part of me says that the extra work to create
and
maintain a separate table plus the has-one/belongs_to relationship makes
it
so doing this just isn’t worth it. I don’t have any problems using this
class, it’s just the growing number of attributes and instance methods
is
approaching 50, and it just smells funny.

Do you do anything about this?

One thing you can do is extract “like” methods into separate modules and
then include the modules in the class. Other than that, I am not sure.

Tim C. wrote:

Do you ever break up a large rails model class into smaller classes for

Do you do anything about this?

Well, in some government forms, i could have 100 fields in a table.

break up if there are the needs for one to many.
or you can do a ONE TO ONE for a group a data
that is not always used.

or you can just show PIECES of a data, at a time.
break it up in forms.

or… you can do lunch.

i vote for lunch…

looks like
composed_ofhttp://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html#M001344might
be worth a look…

On Dec 19, 2007 10:41 AM, gemblon (t.b.)
[email protected]

Depends on what you would define as “large”. I have a 600+ line model
here
that runs fine.

On Dec 20, 2007 6:45 AM, Tim C. [email protected] wrote:

Do you ever break up a large rails model class into smaller classes


Ryan B.