views:

10

answers:

1

UPDATE

Got it to work by using has_and_belongs_to_many

Anyone know why this works ?

Hi,

I get the following error when saving with active record

undefined method `reflect_on_association' for Class:Class

my relationships look like this :

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 looks like this

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

The session_id and contact_id should be saved in the class model

Thanks

Alex

A: 

Right off the bat i would say that as Class is a reserved keyword in Ruby, then using :classes as a association name is the culprit. The reflection code probably tries to singularize the assocation name, getting "class" as a result, and then constantizing it, getting Class and thats where stuff breaks down.

Tanel Suurhans
Thanks, that makes sense and also fixed the issue!Alex
Alex