On 1/15/07, David <i@davidwinter.me.uk> wrote:>
> Hi all -
>
> I''d like to create an abstract model that other certain models can
> inherit from. I know that I''ll need to use the `abstract_model?`
to
> return `true` to set that up.
>
> The reason I''d like to use an abstract model is I''d like
to be able to
> force a sub-class to include a certain attribute if it doesn''t
already
> include it (in the database). Such as ''Title''.
>
> The reason for needing this is that different models I have will be
> used as news categories, so I need a common attribute that all have the
> same name so that in my views I can just call the one accessor with the
> same name.
>
> I hope that makes sense.
>
> Is there anyway I can do this?
The best option is to just add a title column to every table. But if
you really want to use a common base class....
class Foo < ActiveRecord::Base
self.abstract_class = true
end
--
Rick Olson
http://weblog.techno-weenie.net
http://mephistoblog.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
-~----------~----~----~----~------~----~------~--~---