By doing this rails assumes you want to use single table inheritance.
To do
this you have a parent_records table with a type (string) field.
There is a fair bit of information regarding STI kicking around
especially
on the wiki
–
Hi Daniel thanks for the reply.
The thing is, I don’t want to use Single Table Inheritance. I have
several record objects based on TextRecord (which incorporates all text
formatting functions).
I want separate tables for each and everyone: forum_posts, articles,
private_messages, etc.
In this case, you would be best to put the common methods into a module
and
then include this module in the classes
eg
module MyModule
def my_method
do_something
end
end
Put this into the lib directory of your app structure and put the
include
statement into your classes
class PrivateMessage < ActiveRecord::Base
include MyModule
…
end
etc
This will provide the methods as instance methods on your classes.
There is a fair bit of information regarding STI kicking around
In this case, you would be best to put the common methods into a module
statement into your classes
class PrivateMessage < ActiveRecord::Base
include MyModule
…
end
etc
This will provide the methods as instance methods on your classes.
Or do what Tom suggests Thanx Tom. I missed that one
–
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.