I was considering adding some extra properties between a has_many relationship.
For example, I have a Users table, and a Group table. Users can join groups via a :through has_many relationship. I want to add the property of the 'role' of the user in that group.
create_table "groupization", :force => true do |t|
t.integer "user_id"
t.integer "group_id"
t.string "role"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
I was wondering, how can I access the role attribute. I was thinking something like:
user.groups[0].role
Is that a correct approach? I know the syntax is wrong (I tried it); what would the correct syntax be like? Thanks!