Frederick Cheung wrote:
> On Jan 26, 5:51�pm, Paul Mckibbin <[email protected]> wrote:
>> require 'active_record'
>> module TestDB
>> � class Inherited < ActiveRecord::Base
>> � � self.logger
>> � � self.default_timezone :utc
>> � � self.establish_connection(params)
> 
> You should set self.abstract_class = true on this class or
> activerecord might think you're trying single table inheritance.
> 
> Fred

I've used inheritance with many of my models.  To expand upon what Fred 
is saying here, you really need to do two things.  I'll show you an 
example use and then you can configure your own class to use it:

One of my models is an inheritance template:

class InheritanceTemplate < ActiveRecord::Base
  self.abstract_class = true
end

Other models inherit from this template by doing the following:

class MyPage < InheritanceTemplate
  set_table_name "my_pages" #pluralized table name
end

etc.

Notice in the classes that are using the inheritance template you should 
also set the table name so that there's no confusion going on in the 
templates.

-- 
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 [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.

Reply via email to