« kevinpfromnm

Getting an app working with new heroku.com (not herokugarden.com)

Posted by kevinpfromnm.

Generate your app

There’s two possible approaches, either using the hobo gem which is easy with Heroku’s .gems file or by installing hobo as a plugin.

Create your app if you haven’t already

hobo appname # or rails appname if you're going to install hobo as a plugin to be able to use edge hobo
cd appname
git init
git add .
git commit -m "Initial commit"

Make a heroku app to push your changes

heroku create # enter your credentials if prompted (first use only)

As long as you run this within a git initialized directory, it will add a new remote of heroku

git push heroku master

Note: heroku does not have all versions of rails gem available by default. Current list as of this posting is rails (2.3.2, 2.2.2, 2.1.0, 2.0.2). Check http://installed-gems.heroku.com/ for most up to date list. If your most recent version isn’t one of these, make sure to either update the .gems file (see next step) to include your version or change your config/environment.rb to reference one of those rails versions.

Gem Installation

Just add a file to the root of your app called .gems with the following:

hobo -v '0.8.8'

The -v ‘0.8.8’ is optional but a good idea to specify the hobo gem version you wish to use so you don’t accidentally grab a later version with breaking changes in it. Any other gems you might need go on separate lines.

Check this .gems file into git.

git add .gems
git commit -m "Added gemspec file"
git push heroku

Heroku will pick up on the new .gems file and automatically grab appropriate gems.

Plugin installation

This is not much different than the regular hobo edge install but you can’t use submodules with heroku.com at this point.

cd vendor/plugins
git clone git://github.com/tablatom/hobo.git
rm hobo/.git -rf
rm hobo/.gitignore
cd ../../.. # back to your base app directory
git add .
git commit -m "Added hobo plugin."
git push heroku

Final notes

Heroku does not automatically run migrations so you’ll need to run heroku rake db:migrate if you add any migrations.

User contributed notes

  • On September 22, 2009 Bart said:

    -----> Heroku receiving push

    -----> Installing gem hobo 0.8.8 from http://gems.rubyforge.org
    ERROR: Error installing hobo:
    hobo requires mislav-will_paginate (>= 2.2.1, runtime)
    ANy ideas? I tried adding mislav-will_paginate to .gems but no go..

  • On September 27, 2009 nxidis said:

    Created a .gems file in the app dir with the following contents:

    mislav-will_paginate --source gems.github.com

    git add .gems
    git commit -m "Added .gems file"
    git push heroku

    Didn't have to do any of the plugin stuff. Heroku just loaded the gems and off it went.
  • On November 13, 2010 pehrlich said:

    I don't know if other people noticed, but there is a bit of an issue with heroku. With hobo 1.0.1 at least, it accidentally uses case sensitive queries as heroku uses postgresql. This is accounted for on normal search I believe but not on autocomplete.

    Fix as follows:
    - install hobo as plugin
    open app/vendors/hobo/lib/hobo/scopes/automatic_scopes.rb

    Change create_scope to add this line at the start:
    def create_scope
    matched_scope = true #already here
    match_keyword = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"

    repeatedly change each following condition with LIKE to #{match_keyword}