I have two models as subject and teacher
Subject model as
class Subject < ActiveRecord::Base
belongs_to :sclass
has_many :subject_teachers
attr_accessible :sub_name
end
and Teacher model as
class Teacher < ActiveRecord::Base
# attr_accessible :title, :body
has_many :sclass_teachers
has_many :subject_teachers
attr_accessible :fname, :lname, :mob, :email
end
and created their join table as subject_teacher as many to many relationship
class SubjectTeacher < ActiveRecord::Base
belongs_to :subject
belongs_to :teacher
end
but i want to access teacher name in subject model / table how can i do it.
what and where did i write the perfect code so that i get specific teacher name to specific
subject as there are MANY TO MANY relationship?
You would do:
as @Hugo said