Summary of various ruby commands

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

Generation

[sourcecode language="bash"]
$ rails generate integration_test static_pages
[/sourcecode]

Undoing things

[sourcecode language="bash"]
$ 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
[/sourcecode]

Running tests

[sourcecode language="bash"]
$ bundle exec rspec spec/requests/static_pages_spec.rb
[/sourcecode]

Embedded Ruby template

[sourcecode language="rails"]
<% provide(:title, 'About Us') %>
<!DOCTYPE html>
<html>
<head>
<title>Ruby on Rails Tutorial Sample App | <%= yield(:title) %></title>
[/sourcecode]

Unix commands

mv: rename

[sourcecode language="bash"]
$ mv app/views/layouts/application.html.erb foobar
[/sourcecode]

Git commands

Commit, merge, and push
[sourcecode language="bash"]
$ git add .
$ git commit -m "Finish static pages"
$ git checkout master
$ git merge static-pages
$ git push
[/sourcecode]

RVM and bundler integration

[sourcecode language="bash"]
$ 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
[/sourcecode]


Andrew Chaa

another day, another PR