A rails model question

Hi all,

I am a newbie in ruby/rails.

I have a question about my database model:
table1: entities (name, description, author_id …)
table2: relations (source_id, target_id, relation_type) (it describes
the relations between 2 entities and the relation type)

How can I define models using rails, or do I need to redefine my
database schema?

thank you

On Jul 20, 2006, at 2:21 PM, Andy Gao wrote:

database schema?

thank you


Posted via http://www.ruby-forum.com/.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

I’m slightly confused about what you’re trying to do. Regardless, it
sounds like you’re looking for has_many, belongs_to, etc. Those are
the active record commands that allow you to make relationships
between tables. If that sounds like what you want, then go check
them out in Agile Rails book.

-Ben L.

Ben L. wrote:

I’m slightly confused about what you’re trying to do. Regardless, it
sounds like you’re looking for has_many, belongs_to, etc. Those are
the active record commands that allow you to make relationships
between tables. If that sounds like what you want, then go check
them out in Agile Rails book.

-Ben L.

The relation table describe the relationship between 2 entities in
entity table.
So as you say, in entity model:
has_and_belongs_to_many :entity

How can I define the relation table? As far as I know, the relation
table name will be “entities_entities”? and how can I define name of the
table columns (the entity_ids) ?

Thank you for your quick response, Ben.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs