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