Rails Commands

less than 1 minute read

Summary of various ruby commands

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


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

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

Running tests

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

Embedded Ruby template

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

Unix commands

mv: rename

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

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

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