is a Rails 3.1 app running on Ruby 1.9.2 and deployed to Heroku's Cedar stack. It has an RSpec and Cucumber test suite which should be run before commiting to the master branch.
Create aliases:
alias bake="bundle exec rake"
alias cuc="bundle exec cucumber"
alias s="bundle exec rspec"
Run the whole test suite with:
bake
Run individual features:
cuc features/visitor_signs_in.feature
Run individual specs:
s spec/models/user_spec.rb
Tab complete to make it even faster!
When a spec or feature file has many specs in them, you sometimes want to run just what you're working on. In that case, specify a line number:
s spec/models/user_spec.rb:8
cuc features/visitor_signs_in.feature:105
Getting the code:
git clone [email protected]:<organization>/<app>.git
Postgres:
brew install postgres --no-python
Setting up Ruby:
rvm install 1.9.2
rvm use 1.9.2 --default
gem install bundler git_remote_branch heroku taps
App:
cd app
bundle
bake db:create
bake db:schema:load
Install Qt:
brew install qt
For rebasing and maintaining a clean history, edit your ~/.gitconfig to include these aliases:
[alias]
up = !git fetch origin && git rebase origin/master
down = !git checkout master && git merge @{1} --ff-only
For cheap and easy branches:
gem install git_remote_branch
To run the app in development mode, use Foreman:
foreman start
It will pick up on the Procfile and use Thin as the app server instead of Webrick, which will also be used by Heroku's Cedar stack.
git pull --rebase
grb create feature-branch
be rake
This creates a new branch for your feature. Name it something relevant. Run the tests to make sure everything's passing. Then, implement the feature.
be rake
git add -A
git commit
git push origin feature-branch
Open up the Github repo, change into your feature-branch branch. Press the "Pull request" button. It should automatically choose the commits that are different between master and your feature-branch. Create a pull request and share the link in Campfire with the team. When someone else gives you the thumbs-up, you can merge into master:
git up
git down
git push origin master
For more details and screenshots of the feature branch code review process, read this blog post.
We're using Heroku as a hosting provider. Deploying to Heroku is done via git. So, set up your git remotes for each environment:
git remote add staging [email protected]:<app>-staging.git
git remote add production [email protected]:<app>-production.git
Some helpful aliases for accessing staging and production consoles are:
alias staging='heroku run console --remote staging'
alias production='heroku run console --remote production'
To deploy to staging:
be rake deploy:staging
Staging deploys are aliased for convenience:
be rake deploy
To deploy to production:
be rake deploy:production
Using these commands are important because they will compile the asset pipeline.
To access data on Heroku:
heroku console --remote staging
heroku console --remote production
That will drop you into a Rails console for either environment. You can run ActiveRecord queries from there.
To run a rake task on Heroku:
heroku rake db:migrate --remote staging
heroku rake db:migrate --remote production
Any rake task can be run with heroku rake ...
To dump staging or production data into your development environment:
heroku db:pull --remote staging
heroku db:pull --remote production
You will see progress bars for each db index and table.
We can create a database backup at any time:
heroku pgbackups:capture --remote production
View backups:
heroku pgbackups --remote production
To destroy a backup:
heroku pgbackups:destroy b003 --remote production
Transfer production data to staging:
heroku pgbackups:capture --remote production
heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production`
More information in the Dev Center.
To check the status of running app servers, background jobs, cron jobs, etc:
heroku ps --remote staging
heroku ps --remote production
To see the performance of the staging application, see:
https://heroku.newrelic.com/...
To see the performance of the production application, see:
https://heroku.newrelic.com/...
To check if feature is enabled for a user:
Rollout.activate? :feature, user
For example:
Rollout.active? :user_suggests_story, current_user
To enable a feature:
Rollout.activate_user :feature, user
For example:
Rollout.activate_user :user_suggests_story, current_user
Install the Heroku config plugin:
heroku plugins:install git://github.com/ddollar/heroku-config.git
Pull the Heroku config from staging:
heroku config:pull --remote staging
You'll see the Amazon credentials as config vars. You should delete lines that don't apply, like Redis to Go connection strings.