Using Hobo Edge on Rails 3

Blog ยป Using Hobo Edge on Rails 3

Posted on 06 Mar 2011 01:18

!!!Hobo is not yet compatible with rails 3.2 so be sure to have "gem rails, "=3.1" in your Gemrfile.

I describe here installing Hobo Edge on Rails 3 using rvm. And command prompt shows your current gemset. To keep my existing applicaitons happy, I will also define a gemset for Rails 2 Hobo applications.


Followed the instructions on to install rvm

bash < <( curl )

Then edited ~/.rvmrc so that on exiting a project directory the environment returns to system defaults.

export rvm_pretty_print_flag=1
export rvm_project_rvmrc_default=1

Intalled ruby with rvm so that I can create project gemsets under it. And of course we need bundler

rvm install 1.8.7
rvm --default use 1.8.7

RVM uses project and/or ruby specific gems:

rvm gemdir

You can hunt code in gems using rvm gemdir. For example find definition of task in rake.

grep -R 'def task' `rvm gemdir` | grep rake

Then proceeded to install gems that I need globally for development

rvm use @global
gem install bundler
gem install wirble #for irb
gem install utility_belt #for_irb
gem install jeweler
gem install yard

Rails 2

We need to use different gem sets for rails2 and rails3. Having them only in project gemsets are not enough. Then you cannot create projects.

Note that you can always switch to the global gemset: 'rvm use @global' .
Let's create rails2 gemset:

source "$HOME/.rvm/scripts/rvm"
rvm  1.8.7
rvm  @rails2hobo --create
echo Gemset: `rvm gemset name`
gem install rails --version 2.3.11
gem install sqlite3-ruby --version 1.3.3
gem install will_paginate --version 2.3.11
gem install hobo --version 1.0.2
gem install haml  --version 3.0.12
gem install dalli --version 1.0.2
gem install rspec --version 1.3.1
gem install rspec-rails --version 1.3.3
gem install steak --version 0.3.8
gem install capybara --version
gem install shoulda --version 2.11.3
gem install mocha --version 0.9.12
gem install factory_girl --version 1.3.3
# Other usual suspects for testing
# gem install delorean --version 1.0.0 #Change in tests
# gem install database_cleaner --version 0.6.4 #Remove data
# gem install spork --version 0.8.4 #Solid test server
# Fixing the gem versions because future versions might be Rails 2 incompatible

Rails 3

Lets create and switch to rails3 gemset and install Rails3 and Hobo
We'll instal Hobo from github. So that we can easily create projects.

source "$HOME/.rvm/scripts/rvm"
rvm  @rails3hobo --create
echo Gemset: `rvm gemset name`
gem install rails
gem install sqlite3-ruby
gem install hobo --pre
gem install haml
gem install dalli
gem install rspec-rails
gem install steak
gem install capybara
gem install shoulda
gem install mocha
gem install factory_girl
 gem install delorean #Change in tests
 gem install database_cleaner #Remove data
 gem install spork --prerelease #Solid test server

Hobo Rails 3 Reference

Refer to Using Hobo 1.3 to start using Hobo.

Rapid Rails 3 with Hobo.pdf is the Tutorial maintained at LightHouse.


rvm use system #Use the operating system installation
rvm use 1.8.7   #Switching to global gems. Use global gems and use Ruby 1.8.7
rvm use @rails2 #use rails2 with current Ruby
rvm use @rails3 #use rails3 with current Ruby
rvm use 1.8.7@rails3 #use rails3 with Ruby 1.8.7
rvm gemdir

Dynamic Bash Shell Prompt

Shell prompt can show your current git branch and rvm gemset. It saves your fingers. Use or adapt the prompt ~/.bashrc file below. I kept it short so that you can easily extend your existing .bashrc.

if [[ -n "$PS1" ]] ; then #Remember rmv does not like return
function parse_git_branch {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
function rvm_gem_set {
  rvm gemset name | grep -v \/
function proml {
PROMPT_COMMAND='PS1="[$(date +%H:%M)]\
[\u@\h: **/\W] $(rvm_gem_set) $(parse_git_branch) $ "'
PS2='> '
PS4='+ '
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  # This loads rvm


Using gemsets are fine for quickly getting up and running. However, each project should have its gem bundle.

Bundle Rails 2

This is a typical Gemfile for Rails 2 projects:

source ""
gem "rails",                "=2.3.11"
gem "hobo",                 "=1.0.2"
gem "haml",                 "=3.0.12"
gem "will_paginate",        ">=2.3.11"
gem "dalli"
gem "builder"
gem "tzinfo"
gem "system_timer"
gem "sqlite3", :groups => [:test, :development]
group :test do
  gem "factory_girl"
  gem "shoulda"
  gem "mocha"
  gem "rspec",              "= 1.3.1",  :require => nil
  gem "rspec-rails",        "= 1.3.3",  :require => nil
  gem "steak"
  gem "capybara"
  gem  "delorean" #Change in tests
  gem  "database_cleaner" #Remove data
  gem  "spork",        "~> 0.9.0.rc4"
gem 'ruby-debug', :groups => [:test, :development]

Adding Bundle to Rails 2

You need to change

  • config/boot.rb
  • config/environment.rb
  • config/preinitializer.rb


# ... run method modified and extend_environment method added
  class Boot
    def run
    def extend_environment
      Rails::Initializer.class_eval do
        old_load = instance_method(:load_gems)
        define_method(:load_gems) do
          Bundler.require :default, RAILS_ENV        
# ...


#... do |config|
   require "active_support" #This line is added


class Pathname  
  def empty?  
# Fallback on doing the resolve at runtime.  
require "rubygems"  
require "bundler"  

Bundle Rails 3

This is a typical Gemfile for Rails 3 projects:

source ""
gem "rails"
gem "will_paginate"
gem "hobo",        "~> 1.3.0.pre29"
gem "haml"
gem "dalli"
gem "builder"
gem "tzinfo"
gem "system_timer"
gem "pony"
gem "sinatra"
gem "vegas"
gem "yajl-ruby"
gem "redis-namespace"
gem "redis"
gem "sqlite3", :groups => [:test, :development]
group :test do
  gem "factory_girl"
  gem "shoulda"
  gem "mocha"
  gem "rspec",                :require => nil
  gem "rspec-rails",          :require => nil
  gem "steak"
  gem "capybara"
gem 'ruby-debug', :groups => [:test, :development]

If you like this page, please spread the word: diggdel.icio.usFacebook

You can contact me if you have questions or corrections.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License