For this homework, you will further refine your team’s web app by adding associations between some of your previously created model classes and by updating your seed data and actions/views to use these associations. Additionally, you will continue to practice with the version-control system, Git.
You will do this homework as a team; however, each member of your team will be responsible for the completion of a particular task. Each team member will choose one task from the list below to complete. All team members must do a different task. If your team has only three members, then ignore Task 4.
Similar to previous homeworks, there will be four tasks (Tasks 1 through 4); however, this time the tasks are more inter-related. Each task will have the same four parts:
Implement two one-to-many associations, as shown in the following figure. In particular, you must create the associations labeled with your task number. Your Rails model associations must match the class diagram exactly—including the role names on the association ends. Furthermore, each has_many
/belongs_to
declaration must include class_name
, foreign_key
, and inverse_of
arguments (see the Rails Guides for documentation).
Additionally, you must follow these task-specific instructions:
Mortgage
class, add an optional: true
argument to the belongs_to
declaration for the Property
object, so Mortgage
objects can be created without associated Property
objects.Appraisal
class, add an optional: true
argument to the belongs_to
declaration for the Property
object, so Appraisal
objects can be created without associated Property
objects.Appraisal
class, add an optional: true
argument to the belongs_to
declaration for the Mortgage
object, so Appraisal
objects can be created without associated Mortgage
objects.Inspection
class, add an optional: true
argument to the belongs_to
declaration for the Property
object, so Inspection
objects can be created without associated Property
objects.Update the seed data as follows. For each new model association, your seed data must contain at least 5 instances of the associations (i.e., links). Furthermore, at least 3 of the association links must be associated with the same model object (i.e., from the “one” side of the association). You may reuse your existing seed objects or create additional seed objects to meet these requirements.
In creating these association links, you may need to coordinate with your teammates. For example, for model classes with multiple associations to other classes, possibly from different tasks, it makes sense that two teammates would each add the association links for their task to the same shared set of seed objects.
Using your newly created associations, you must update the model CRUD pages as follows. The specific parent and child model classes for each task appear further down.
Update the parent show
page such that it includes a table listing all the child objects that the parent object has. The table must be inserted below the usual parent show
info and be styled like the table in the child index
page.
Update the child index
page such that a new column is added to the table. The column must be titled col-heading, and it must display the parent-attr attribute of the parent object to which the child belongs. All CRUD links must be removed from the index
page (i.e., the create, show, update, and destroy links). Each parent name must hyperlink to the associated parent object’s show
page.
Update the child show
page such that it now lists the name
attribute of the parent object that the child object belongs to. The name must hyperlink to the associated parent object’s show
page. The “Back” and “Update” links must be removed from the child show
page.
The parent edit
form must now include the equivalent of an index
page for child (including all the usual CRUD links found on the index
page). The CRUD child functionality must now all be specific to a particular owner. For example, if a user on the parent edit
form click the “Create Property” link, then the child new
form must be creating a child that belongs to the parent. Successful submission of the form must redirect the user to the associated parent object’s show
page. Similarly, successful updating or destroying of a child object must also redirect to the associated parent object’s show
page.
Here are the per-task mappings:
Owner
Property
name
Appraiser
Appraisal
name
Lender
Mortgage
firm
Inspector
Inspection
name
Update your project’s home page so that it now lists your name (no hyperlink) followed by the following two links:
Owner
index
page.Property
index
page.Appraiser
index
page.Appraisal
index
page.Lender
index
page.Mortgage
index
page.Inspector
index
page.Inspection
index
page.Before you can submit, all team members must have merged their code into the master branch and pushed the updates to GitHub. If a team member does not complete his/her work on time, you may submit without his/her contribution.
To submit your team’s work, you must “tag” the current commit in the master branch:
git tag -a hw7v1 -m 'Tagged Homework 7 submission (version 1)'
git push origin --tags
To grade your work, I will check out the appropriate tag, and run it on my machine.
Note that if for some reason you need to update your submission, simply repeat the tagging process, but increment the version number (e.g., hw7v2
, hw7v3
, hw7v4
, etc.).
Total marks: 100
Below, the top-level number is the items total point value. If an item is not submitted at all, 0 points will be awarded for that item. The sub-bullets indicate standard deductions for errors in a submitted item. The deduction list below may not be complete because there may be mistakes that we did not expect. The deduction for an unexpected mistake will be assessed at the time it’s discovered and will reflect how severe the instructor thinks the mistake is.
40 Two model associations (20 each)
show
page with new tableindex
page with new columnshow
pageedit
page and child CRUD actionsOther deductions: