For this homework, you will create simple model classes in Rails, write tests to run them, and practice using the basic version control features of 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.
Once everyone has selected their tasks, you must follow the workflow in this instructional video. Follow all the steps carefully, including submitting your team’s work as a GitHub release.
The specific tasks are detailed below. For each one of them:
rails generate model ...
Model classes to create:
Add these validations to class School
:
length
name
must be 50 characters or less.format
url
must follow the general format of a URL.inclusion
category
must be "elementary"
, "middle"
, or "high"
.uniqueness
url
must be unique.presence
name
, url
, and category
must have values.numericality
founded
(year founded) must be less than or equal to the current year.Model classes to create:
Add these validations to class TeachingEvaluation
:
length
comment
must be 5000 characters or less.format
metareviewer
must following the following employee-ID format: a-123456-789 (i.e., a lowercase letter followed by a hyphen followed by 6 digits followed by a hyphen followed by 3 digits).inclusion
median_rating
must be "poor"
, "fair"
, "good"
, or "excellent"
.uniqueness
comment
must be unique. (No two reviews should be the same. If they were it would be a sign of poor quality.)presence
median_rating
, metareviewer
, and comment
must have values.numericality
respondents
must be greater than zero.Model classes to create:
Add these validations to class Student
:
length
last_name
must be 30 characters or less.format
dob
(date of birth) must follow the following date format: 01-23-1945 (i.e., a two-digit month followed by a hyphen followed by a two-digit day followed by a hyphen followed by a four-digit year).inclusion
honorific
must be "Mr"
, "Ms"
, "Miss"
, "Master"
, or "Mx"
.uniqueness
last_name
must be unique, because the school allows only one child per family name (which is very strange indeed!).presence
honorific
and last_name
must have values.numericality
iq
must be a value from 0 (the lower bound for an IQ) to 300 (the highest IQ ever speculated to be possessed by a person).Model classes to create:
Add these validations to class HomeworkGradeSheet
:
length
text
must be no more than 10000 characters.format
signature
must be a 40-digit hex string. Each digit must be one of the following characters: 0123456789abcdef
(case sensitive).inclusion
grade
must be "A+"
, "A"
, "A-"
, "B+"
, "B"
, "B-"
, "C+"
, "C"
, "C-"
, "D+"
, "D"
, or "F"
.uniqueness
signature
must be unique.presence
grade
, signature
and feedback
must have values.numericality
score
must be between 0 and 100.Total points: 100
Below, the top-level number is the items total point value. If an item is not submitted at all or it is irredeemably broken, 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.
Other deductions: