Your interpretation:>
> module SharedStuff
> self.abstract_class = true
> self.table_name = ''footable''
> self.table_name = ''bartable''
> end
>
> class Foo < ActiveRecord::Base
> include SharedStuff
> end
>
> class Bar < ActiveRecord::Base
> include SharedStuff
> end
isn''t the same as what is mentioned in that posting... including the
SharedStuff module just makes those methods available to your model,
each model should still spec its own table_name. As you are set,
everything reads from ''bartable'' if I understand the internals
correctly.
I prefer the abstract class method, and have a class GenericModel, which
defines all the default behaviors for all the other models. Centralized
cache management, polymorphic join management, all that ugly stuff you
don''t want to type more than once.
Every other model inherits from GenericModel, overriding default
behaviors if necessary. But GenericModel has no data fields, no table
names, just methods.
I also use a GenericController, and for almost all of my other
controllers, they contain nothing more than a before_filter, sometimes a
different layout, and any actions unique to their model. index, new,
edit, save, update... they all reside in GenericController. Actions not
done by all controllers, like deep copy, or PDF generation are in each
controller that supports it.
--
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
-~----------~----~----~----~------~----~------~--~---