Rails Commands

Summary of various ruby commands

.erb: embedded ruby, the primary template system for including dynamic content in web pages.


$ rails generate integration_test static_pages

Undoing things

$ rails generate controller StaticPages home help
$ rails destroy  controller StaticPages home help

$ rails generate model Foo bar:string baz:integer
$ rails destroy  model Foo

$ rake db:migrate
$ rake db:rollback
$ rake db:migrate VERSION=0

Running tests

$ bundle exec rspec spec/requests/static_pages_spec.rb

Embedded Ruby template

<% provide(:title, 'About Us') %>
<!DOCTYPE html>
    <title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>

Unix commands

mv: rename

$ mv app/views/layouts/application.html.erb foobar

Git commands

Commit, merge, and push

$ git add .
$ git commit -m "Finish static pages"
$ git checkout master
$ git merge static-pages
$ git push

RVM and bundler integration

$ rvm get head && rvm reload
$ chmod +x $rvm_path/hooks/after_cd_bundler
$ cd ~/rails_projects/sample_app
$ bundle install --without production --binstubs=./bundler_stubs
Rails Commands