For this assignment, you must augment your birthday tracking application to add some sophistication. The application should be able to detect conflicts – dates when you have more than one birthday to attend to. It should also validate the form input to make sure it is in the right format, and store birthdays as “Date” in the database.
Due: October 22, 2012
This assignment builds on the results of Assignment 2. Therefore, you need to have a working copy of the code from Assignment 2. If you were unable you complete the assignment successfully, the instructor will make a working version available. You can choose to continue using your own code from Assignment 2, or to start from the code the instructor has provided. I strongly encourage you to use your own code if you completed the assignment; learning about someone else’s code takes a lot of work.
Modify the Person model to store the birthday as a Date type in the database rather than using a string. Make sure the input from the input form is correctly converted into a Date type.
Add a new model called Family. Each family can have multiple people in it. Add a new view page that allows people to create new Families. And modify the Person input view page to allow them to choose which Family the person being entered belongs to. The list of people and birthdays should include which Family a person is part of. (Note, this should be an explicit has_many relationship between models)
You should modify your controller to validate that the form data is in the correct format. Strings are strings, names don’t contain spaces, none of the fields are blank, etc. Your application should display an appropriate error message when an incorrect input is detected.
When viewing a single person, display of list of “conflicts” – of other people who share that same birthday. So, for example, my birthday is November 14th. So the page about me should list everyone else in the system who has the same birthday as me.
When writing code, you should always document what the code does, and why. There are two pieces to the documentation:
In addition, for this assignment I would like you to create a file in the
doc directory that
describes the workflow of your application. This file should be named
doc/workflow.txt it should be
a plain text file. Basically, it should contain:
You are not required to do any of these extras, but including one or more of them in your assignment will lead to extra credit.
At 5pm on the due date, I will collect the assignments out of the git repository
<username>/assign3. Be sure that
your assignment is in the repository, in the correct directory, and don’t forget to
git commit and
git push. Make
sure the application runs on the server as part of my grading will be to run the program and enter birthday information
October 22, 2012 at 5pm
date. This will be fine. You can access individual parts of the date through its methods:
date.year. Also, you can create forms for inputing dates using the
<%= f.date_field(:birthday) %>
Person.all. You can include clauses in this to limit this. For example, to only get people with the first name of “Rick”, you could do
Person.where(:first_name => "Rick").all. To detect conflicts, you can limit it to only people with a specified birthday:
@conflicts = Person.where(:birthday => @person.birthday).all
Then you can print out this list of people in your
assign2git repository to a new
assign3repository, copy all of the files over, and then commit the changes.
new_repo assign3 cp -r assign2/* assign3
Then, edit your
config/database.yml file to point to a new, assign3 database, run your existing migrations on that database, and commit your changes.
nano config/database.yml rake db:migrate git add . git commit git push origin master