I have 2 models - Teacher and Subject. A want to connect them via Join table with name Qualification.
It looks like i
In rails 3 the best way is make intermediate table qualification through migration
the attributes will be like of this table
subject_id:integer teacher_id:integer
and also make class of qualification like this
class Qualification < ActiveRecord::Base
has_many :subjects
has_many :teachers
end
and then define other two models like
class Teacher < ActiveRecord::Base
has_many :qualifications
has_many :subjects, :through => :qualifications
end
class Subject < ActiveRecord::Base
has_many :qualifications
has_many :teachers, :through => :qualifications
end
and read this link carefully also
http://blog.hasmanythrough.com/2007/1/15/basic-rails-association-cardinality