Rails I
3 credits
Satellites Model Created | 5 |
Satellites Model is Self-Referrential | 10 |
Satellites Model contains correct validations | 5 |
Index view created according to specs | 15 |
Edit and New pages and forms created and functioning | 20 |
Show page created and showing correct information | 15 |
Navigation partial created and functioning | 20 |
Layout created and used | 10 |
Total | 100 pts |
To practice using Views
For this lab you will be creating a rails application that will allow for information about the sun, planets, and their moons to be stored and viewed. For the purposes of this lab all of these things will be referred to as satellites since everything orbits around something else.
To start the lab you will need to create a Satellite model (make sure you name it Satellite exactly). Each satellite will have a name (name:string) which you should validate as being present and unique, and a parent (parent_id:integer) which is not required. You will then need to setup this model with the validations mentioned before and you should make this model self-referrential so that each satellite can have one parent and can have many satellites.
Once you model is setup you will need to create 1 layout and 4 basic views to go with the model. The layout is up to you in how you set it up and what you include in it. The 4 views should be for the index, new, edit, and show actions.
This index view should show a list of all of the satellites stored in the application and should provide a show, edit, and destroy link for each. The page should also have a single link to create a new satellite.
The new and edit pages can be almost identical. Each should contain a form that allows for a satellite to be created or edited. It will need a text field for entering a satellites name and a select component for choosing the satellites parent if one exists. The select component should always contain a list of all of the satellites in the application.
The show page should list the information about the current satellite including its name, the name of its parent if there is one, and a list of its satellites is they exist.
Finally, each page should have a list of links to act as navigation for that page. The navigation list should always include the sun and the satellites of the sun and should also show links for child satellites when they exist. For example, when viewing the show page for the Mercury, the navigation list should include the sun and all of its satellites and nothing more because Mercury doesn't have any satellites of its own. However, when the show page for Earth is viewed it should have the sun and satellite links but should also include a link for the moon. This navigation section should be created using a single partial.
Attached is a rails project that contains everything you will need to start the project. It is missing the model and the views that you will create.