- Building a full CRUD App with a single resource
This lab will practice building out the full MVC for a CRUD app for a single resource
As with other labs in this section, there is some starter code in place. To get set up, run:
$ bundle installYou can work on this lab by running the tests with learn test. You can run the Rails server with:
$ rails sFor all the deliverables below, if you use any Rails generators to create models
controllers or views, make sure to use the --no-test-framework flag to avoid
overwriting the existing tests.
Create a Restaurant model with the following attributes:
namethat is astringtypedescriptionthat is astringtypecitythat is astringtypestar_ratingthat is anintegertypecuisinethat is astringtype
Your Restuarant model should also:
- validate the restaurant's name to ensure that it is present and unique (no two restaurants can have the same name)
- validate the restaurants star_rating is between 1 and 5
Run the migrations after creating your models.
Ensure that the tests for the models are passing before moving forward. To run the tests for only the model files, run:
$ rspec spec/modelsNext up is to set up RESTful actions for our restuarants. Build out CRUD for our Restaurant app so we can start serving delicious food! This can be test driven with the following:
$ rspecGood luck and have fun!