Hi
Thanks for your reply.Here in junction table user_groups I have the
additionl storing like
id integer not null default nextval(‘user_groups_id_seq’::regclass)
contact_id | integer |
group_id | integer |
group_user_type_id | integer |
Hi
Thanks for your reply.Here in junction table user_groups I have the
additionl storing like
id integer not null default nextval(‘user_groups_id_seq’::regclass)
contact_id | integer |
group_id | integer |
group_user_type_id | integer |
Sijo
Ahhh - I see. You are not only recording the contacts belonging to a
group, but also different kinds of groups.
May I suggest you actually create another model to handle group_types,
something like this:
class Contact
has_and_belongs_to_many :groups
has_many :grouptypes, :through => :groups
end
class Group
has_and_belongs_to_many :contacts
belongs_to :grouptype
end
class GroupType
Has a text field called “name”
has_many :groups
has_many :contacts, :through => :groups
end
Grouptype.find_by_name(“Manager”).contacts
etc.
Am I on the right track here?
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.