For the long weekend, we'd like you to combine your knowledge of Sinatra + SQL to build an app to create, read, update and delete squads and students in their respective squads.
You should have two tables, squads and students. Keep this relationship in mind when you build your tables - One squad has many students. We are also going to assume that all students are in squads (meaning that there can never be a student who is not part of a squad)
Students should have a/an:
- Unique ID
- Squad ID
- Name
- Age
- Spirit Animal
Each squad should have a:
- Unique ID
- Name
- Mascot
Your students table should have a foreign key that links it to the squads table.
BEFORE YOU ADD ANY ROUTES OR EVEN A LINE OF RUBY CODE, TEST YOUR DATA IN PSQL AND MAKE SURE YOU CAN SUCCESSFULLY JOIN THE TABLES
/
- this is your root route and since there is nothing here, you can simply add this code to your app.rb
so that it redirects to a route with an erb page.
get '/' do
redirect '/squads'
end
/squads
- this route should take the user to a page that shows all of the squads
/squads/new
- this route should take the user to a page with a form that allows them to create a new squad
/squads/:squad_id
- this route should take the user to a page that shows information about a single squad
/squads/:squad_id/edit
- this route should take the user to a page with a form that allows them to edit an existing squad
/squads/:squad_id/students
- this route should take the user to a page that shows all of the students for an individual squad
/squads/:squad_id/students/:student_id
- this route should take the user to a page that shows information about an individual student in a squad
/squads/:squad_id/students/new
- this route should take the user to a page that shows them a form to create a new student
/squads/:squad_id/students/:student_id/edit
- this route should take the user to a page that shows them a form to edit a student's information
/squads
- this route should be used for creating a new squad
/squads/:squad_id/students
- this route should be used for creating a new student in an existing squad
/squads
- this route should be used for editing an existing squad
/squads/:squad_id/students
- this route should be used for editing an existing student in a squad
/squads
- this route should be used for deleting an existing squad
/squads/:squad_id/students
- this route should be used for editing an existing student in a squad
- Style your application!
- Add a column to the students table called
is_squad_leader
, which is aboolean
. When you list out the students in a squad, their name should be bolded. - Use your knowledge of JavaScript and AJAX to make the page more dynamic.