The actual RottenPotatoes starter app you will use is in another public repo: saasbook/rottenpotatoes-rails-intro. Fork that repo to your own GitHub account, and then clone your fork:
$ git clone [email protected]:your_github_username/rottenpotatoes-rails-intro.git
If you are using AWS Cloud9, consider editing your gemfile to use the same version of Ruby as currently installed, if it's only a partial version away. Currently, this is 2.4.1 instead of 2.4.0. Otherwise, you'll need to download Ruby 2.4.0 and switch to it using RVM. It's easier to just change the gemfile to use 2.4.1.
Whenever you start working on a Rails project, the first thing you should do is to run Bundler, to make sure all the app's gems are installed. Switch to the app's root directory (presumably rottenpotatoes-rails-intro
) and run bundle install --without production
(you only need to specify --without production
the first time, as this setting will be remembered on future runs of Bundler for this project).
Finally, get the local database created:
$ rake db:migrate
Self Check Question: How does Rails decide where and how to create the development database? (Hint: check the db
and config
subdirectories)
Therake db:migrate
command creates a local development database (following the specifications inconfig/database.yml
) and runs the migrations indb/migrate
to create the app's schema. It also creates/updates the filedb/schema.rb
to reflect the latest database schema. Note: it's important to keep this file under version control.
Self Check Question: What tables got created by the migrations?
Themovies
table itself and the rails-internalschema_migrations
table that records which migrations have been run.
Now insert "seed data" into the database--initial data items that the app needs to run:
$ rake db:seed
Self Check Question: What seed data was inserted and where was it specified? (Hint: rake -T db:seed
explains the seed task; rake -T
explains other available Rake tasks)
A set of movie data which is specified in db/seeds.rb
At this point you should be able to run the app locally (rails server
) and navigating to http://localhost:3000/movies
in your browser. If you are using c9, use rails s -p $PORT -b $IP
and navigate to the link generated within c9.