One to Many Relational database

Hi All,

  I have established the relationship and everything is working

well, but I need to display as descried below.

I have two tables Student and Teacher.

In my application one teacher has several students under him, so how do
I display the students under only that particular teacher at a given
time.

Thank You

teacher model:
has_many :students

student model:
belongs_to :teacher

in controller:
@teacher = Teacher.find(…your code…)

then all his students can be accessed:
@teacher.students

for example
@teacher.students.each do |student|
…do something with student
end

Thorsten M. wrote:

teacher model:
has_many :students

student model:
belongs_to :teacher

in controller:
@teacher = Teacher.find(…your code…)

then all his students can be accessed:
@teacher.students

for example
@teacher.students.each do |student|
…do something with student
end

How to student as a nested resource to teacher.
Such that when I perform a show action an albums, I should be able to
view only the photos associated with it and not all the photos of the
table