Sample Project - Blogger
For these tutorials we’ve built a very simple three-model sample project named Blogger. You can use it to complete all the exercises and experiments described.
Check Out the Code
From your terminal, change to a directory where you want to store your project. Then, checkout the code from GitHub:
1 2 |
|
If you’re using RVM, it will ask if you want to trust the include .rvmrc
file. Type yes
and hit enter.
Setup Initial Dependencies
Then you’ll want to run the Bundler system to resolve and install dependencies:
Terminal
$
|
|
Development Database
The repository has a database with a few sample articles in it to make your testing easier. But we don’t want to bother with committing that file every time we change the data. Tell Git to ignore changes to that file with this instruction:
Terminal
$
|
|
Use Pattern
Unless otherwise specified, the exercises for a single section are designed to be completed independently of the other sections. You should always start with this original copy of Blogger.
Starting a Branch
The easiest way to manage that is by creating a branch. If we are starting the section entitled "Local Authentication with Devise", you could create and checkout a branch like this:
Terminal
$
|
|
Bring Up a Server, Console, and Terminal
It’s a good idea to open three command windows or tabs:
- Run your server with
bundle exec rails server
- Run your console with
bundle exec rails console
- Have available for command-line operations like running generators, Rake, etc.
Completing the Exercises
You can then work through the exercises. It’d be a good idea to commit your results after each exercise, like this:
Terminal
$ $ |
|
The `-A` flag above will cause any files deleted from the filesystem to be removed from the branch in Git.
Reset
When you complete a section, run git status
to make sure there are no un-committed changes.
Then switch back to the master branch so you’re ready to start the next section:
Terminal
$
|
|
Other Git Tips
- Want to trash everything since your last commit? Run
git reset --hard
- Want to try an experiment while doing exercises? You can branch from a branch using the same
git checkout -b branch_name
when you’re on the source branch. - Forget the name of your branch? Run
git branch
and you’ll see a list of all branches with an*
next to the current one. - Curious what files have been changed? Run
git status