Ruby on Rails Applying Model to Two Other Models

Hi, I know this is probably a basic question but I am relatively new to
Ruby on Rails.

I have a website in which I have three models: courses, students, and
works. The website is supposed to be a grade keeper. A course has many
works, like a test. You can add a work to a course, but I want that work
to
be distributed as single works to each student in that course as well.
Does
anyone know how I would be able to do this?

Thank you in advance,

Jacob G.

On 20 January 2015 at 22:48, Jacob G. [email protected] wrote:

Hi, I know this is probably a basic question but I am relatively new to Ruby
on Rails.

I have a website in which I have three models: courses, students, and works.
The website is supposed to be a grade keeper. A course has many works, like
a test. You can add a work to a course, but I want that work to be
distributed as single works to each student in that course as well. Does
anyone know how I would be able to do this?

If I understand correctly is it just that you want
Student has many works
Work belongs to student

Or possibly you need a has_and_belongs_to_many between them.

If not then please explain the problem more carefully. In particular
I don’t know what you mean by ‘distributed as single works’.

Have you already worked right through a good tutorial such as
railstutorial.org (which is free to use online)? If not then I
suggest you do that before anything else, it will give you a good
grounding in rails.

Colin

On Jan 20, 2015, at 5:48 PM, Jacob G. [email protected] wrote:

Hi, I know this is probably a basic question but I am relatively new to Ruby on
Rails.

I have a website in which I have three models: courses, students, and works. The
website is supposed to be a grade keeper. A course has many works, like a test.
You can add a work to a course, but I want that work to be distributed as single
works to each student in that course as well. Does anyone know how I would be able
to do this?

This feels like it’s lacking another model. I did a system where there
were quizzes after a medical Continuing Education presentation, and
there was the following setup:

User (has_many examinations)
Examination (belongs_to user, belongs_to test) [also stores the
individual’s answers to each question]
Test (has_many examinations)

I won’t get into the questions and answers here, but this should give
you a possible direction. The idea is that a Test is a template – the
mimeograph master if you go back that far. There are many examinations
derived from that test, and each examination is referencing a single
user and a single test (master). How that exam gets filled out is unique
to the user, and I think that’s the missing model you are looking for.

Walter