Being a rails newbie, I appear to have hit a large wall.

I am trying to create an online gradebook using rails, where I and other
teachers at my school can record students' grades for all their homework
assignments.

students           assessment1         assessment2         assessment3
--------           -----------         -----------         -----------
Bart Simpson          12                    15                  9
Lisa Simpson          7                     6                   14
Charlie Brown         12                    14                  17

I would like teachers to be able to dynamically add columns for new
assessments as they occur, and understand that this is not such a simple
task.

It is obvious that I need a join model in which to store the grades as
there will be many students and many assignments, and each grade will be
linked to both a specific assignment and specific student.

So I have written my models as follows:

   1. class Student
   2. has_many :gradations
   3. has_many :assignments, :through => :gradations
   4. end
   5. class Gradation
   6. belongs_to :student
   7. belongs_to :assignment
   8. end
   9. class Assignment
  10. has_many :gradations
  11. has_many :students, :through => :gradations
  12. end

So far so good right?
Well I have since spent an infuriating amount of time fiddling about
querying the models, and I can't for the life of me figure out how to
pull out the data as in the table above. i.e. listing all the students'
grades for each assignment.
I wonder if there is somebody out there who can put me out of my misery.
Or maybe I am barking up the completely wrong tree? Is there an easier
way of doing this that I have totally overlooked?..
Please, somebody help me. I don't want to lose any more hair over this.

I have posted a more detailed picture of my dilemma at
http://railspool.blogspot.com/
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to