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? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Tim Case 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..... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
looks like composed_of<http://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html#M001344>might be worth a look... On Dec 19, 2007 10:41 AM, gemblon (t.b.) <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Tim Case 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..... > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Case <tcrails1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> looks like composed_of<http://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html#M001344>might be worth a look... > > > > > On Dec 19, 2007 10:41 AM, gemblon ( t.b.) < > rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > > > Tim Case 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..... > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---