Do I need other kinds of relationships?
Yeah, you will need more relationships. However, it depends how extravagant you want to make it. You mentioned searching by teacher, administrator, and counselor name. I'm not certain how these all relate to one another, so I'm just going to stick to teacher.
I suggest creating a Teacher model where Teacher has_many :students - if a teacher has all students you may not want to bother with this association. Next you need to create a table/model to hold the user's behavior reports. I'm just going to call this report, but you should probably rename it as you have a better understanding of the domain. This report can belong to both teacher and student (it has a teacher_id and student_id). Here is the end result:
class Teacher < ActiveRecord::Base
class Report < ActiveRecord::Base
Now you need to make a form for creating the reports. I'm assuming you let the teachers login to the system somehow, so you already have the teacher_id value. You just need to provide a way to select the student value:
# in reports_controller.rb or wherever
@teacher = Teacher.find(session[:teacher_id]) # you probably want to handle this elsewhere/differently
@report = Report.new
# in new.rhtml
<%= start_form_tag :action => 'create' %>
...other report fields...
<p>Student: <%= collection_select :report, :student_id, @teacher.students, :id, :name %></p>
<%= end_form_tag %>
# back in controller
@report = Report.new(params[:reports])
@report.teacher = Teacher.find(session[:teacher_id]) # again, the teacher will probably be fetched some other way
This will only show the teacher's students in the select menu. If you wanted to show all students in that menu you would do:
collection_select :report, :student_id, Student.find(:all), :id, :name
You would probably want to set that to a @students instance variable in the controller to keep the finds out of view.
Under the circumstances, is what I have in mind too non-standard?
Nope, seems pretty normal to me. Unless of course I'm way off base.
The searching might be a little tricky, but I suggest getting this working first.
- Free Ruby on Rails Screencasts