I'm trying to find the relations between Surgeon and Appointments.
2.0.0-p195 :001 > surgeon = Surgeon.first
Surgeon Load (0.1ms) SELECT "surgeons".* FROM "surgeons" ORDER BY "surgeons"."id" ASC LIMIT 1
=> #<Surgeon id: 5, name: "Micheal Gorbachev", created_at: "2014-04-13 07:15:42", updated_at: "2014-04-13 07:15:42">
2.0.0-p195 :008 > surgeon.appointments
NameError: uninitialized constant Surgeon::Appointment
but this works
2.0.0-p195 :007 > surgeon.association :appointments
2.0.0-p195 :007 > surgeon.association :appointments
=> #<ActiveRecord::Associations::HasManyAssociation:0x00000002a46850
@reflection=#<ActiveRecord::Reflection::AssociationReflection:0x000000030dc4d0
@macro=:has_many, @name=:appointments, @scope=nil, @options={},
@active_record=Surgeon(id: integer, name: string, created_at: datetime,
updated_at: datetime), @plural_name="appointments", @collection=true>,
@owner=#<Surgeon id: 5, name: "Micheal Gorbachev", created_at: "2014-0
this is my Model
class Surgeon < ActiveRecord::Base
has_and_belongs_to_many :instruments
#section 2
has_many :appointments
has_many :interventions, :through => :appointments
end
class Intervention < ActiveRecord::Base
has_and_belongs_to_many :instruments
#section 2
has_many :appointments
has_many :surgeons, :through => :appointments
end
class Instrument < ActiveRecord::Base
has_and_belongs_to_many :surgeons
has_and_belongs_to_many :interventions
end
class Appointments < ActiveRecord::Base
#section 2
belongs_to :surgeon
belongs_to :intervention
end
Models must be named in singular, not plural.
class Appointment < ActiveRecord::Base