Undefined method `reflect_on_association 'for a class: class error while saving

UPDATE

To work, use has_and_belongs_to_many

Does anyone know why this works?

Hi,

When saving with an active recording, the following error appears

undefined method `reflect_on_association' for Class:Class

my relationship is as follows:

class Contact < ActiveRecord::Base
  has_many :classes
  has_many :sessions, :through => :classes
end

class Class < ActiveRecord::Base
 belongs_to :session  
 belongs_to :contact
end

class Session < ActiveRecord::Base
   has_many :classes
   has_many :contacts, :through => :classes
end

My request is as follows

{"commit"=>"Submit", "contact"=>{"address"=>"", "postcode"=>"", "notes"=>"", "session_ids"=>"2", "phone"=>"", "last_name"=>"w", "email"=>"", "first_name"=>"w"}}

Session_id and contact_id must be stored in the class model

thank

Alex

+3
source share
1 answer

, Ruby, : . , , , "", , , .

+3

Source: https://habr.com/ru/post/1750820/


All Articles