On Jul 1, 6:05 pm, Ar Chron <[email protected]> wrote:
>
> class GenericModel < ActiveRecord::Base
> self.abstract_class = true
> # generic implementations shared by all models
> # my app has some 30 'generic' model methods, relationship
> # management, cache management, pdf generation, etc
> end
>
> class Project < GenericModel
> # project-specific methods
> # project has only 5, 2 of which override GenericModel
> # definitions
> end
>
>> Project.table_name
--- generic_models
=> nil
To preserve ARs default table naming and related conventions a model
class MUST inherit directly from ActiveRecord. This is apparently an
artifact of how the AR class is actually assembled from modules "on-
the-fly" as it were. If you do use the generic_model class then you
must provide in each descendant class the actual table name the class
should use. The project class should include this:
--->
class Project < GenericModel
set_table_name "projects" # do not forget to pluralise the table
name!
# project-specific methods
# project has only 5, 2 of which override GenericModel
# definitions
end
<---
HTH
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---