Welcome to Week 7's Lab!

By this point of the Rails Decal, you now have the full power of Models, Views, and Controllers. You've learned about editing your database schema, associating models, validating data information, as well as the all-powerful scaffolding tricks.

Today we're going to be working with a simple task: creating a university and student roster.

Run rail new model-lab -J and let's get started :)

Note: -J is the same thing as --skip-javascript and gets rid of any files related to Javascript

TOCCD (The official cross-campus database)

Universities all across the U.S. are struggling to adopt new technologies. If you've ever tried registering for a class on campus, you know that our software could use some updating. Recently several chancellors of colleges across the nation are came together and decided to create a collective database of their all their students. They picked the RoR Decal to build it for them!

With today's lab, we'll be putting together everything we've learned so far in the course to create this for them. This time though, we'll have to be comprehensive in our tasks, ensuring that students can be distinguished based on the college they go to and we be able to edit their information efficiently.

We won't be giving you anything to start off with - just a few components along the way.

Let's get to it

Task 1: Brainstorming a schema and generating our models

As always, the first thing we want to do is plan ahead with our schema and models. In this case, we have two distinct models: Student and University . Here are the properties we've been told we need on these models:

Not only do we need these models, but we also want all the routing and controller methods done for showing, creating, updating, and deleting both kinds of objects. The previous homework had you walk through this piece by piece - filling in the controller methods, editing your routes, and syncing them up with the model. Since a lot of these tasks end up being repetitive, Rails gives us a powerful generating tool: scaffold

We can use scaffold to not only generate the model, but automate the creation of the respective controller methods and routing in relation to all the uses of that model. Let's try using it for our University model:

rails generate scaffold University name:string rank:integer