How to create new row (relationship)?

Hi,

I have some problems creating new rows based on relationship :slight_smile:

I’m using has_and_belongs_to_many

Groups <=> ContactsGroups <=> Contacts

When I type in Irb this:
Group.find(4).contacts

I get the following result, which is fine :smiley:
=> [#<Contact:0x493afa4 @attributes={“accepted_at”=>nil…

But when I try to create new contact I get error :frowning:

Group.find(4).contacts.create
=> NoMethodError: undefined method `group_id’

How can I create new contact through Group.find(4).contacts.create ?

Thanks for any response :smiley:

Having the same problem?

Just add to contacts in my case :smiley:

attr_accessor :group_id

It worked :slight_smile: