- 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 install
You can work on this lab by running the tests with learn test
. You can run the Rails server with:
$ rails s
For 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:
name
that is astring
typedescription
that is astring
typecity
that is astring
typestar_rating
that is aninteger
typecuisine
that is astring
type
Your User
model should also:
- validate the restaurant's name to ensure that it is present and unique (no two users can have the same username)
- 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/models
Next 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:
$ rspec
Good luck and have fun!