Installing Ruby 1.8 and & 2.3.8 for ActiveSalesforce

February 23rd, 2011

I’ve been working for the past week or two on my Ruby for Force.com Developers series but have run into a few snags. First of all the ActiveSalesforce adapter doesn’t work with Rails 3.0.3. There’s a post on the message boards where Quinton Wall mentions that he is working with Heroku and is looking to write a new Ruby toolkit. Any new¬†toolkit will be REST-based and move away from the active-record model but no ETA as of now.

So my other alternative was to go the REST route since I’ve already done it in Java. Pat Patterson has a great Cookbook Recipe but it uses the Sinatra framework and has confusing instruction on setting up na SSL reverse proxy with different HTTP servers. Setting up SSL with Rails 3.0.3 is a breeze and since my Ruby series is already headed down that path, I decided to stick with Rails. I quickly spun up a new Rails app and started working on the OAuth dance. I had no problems authorizing my app with salesforce.com and returning the code, however, when trying to POST to salesforce.com to get my token, I received a mysterious “end of file” error. Based upon the Ruby message boards, a number of people are having struggles with OAuth so I enlisted Quinton to see if he can help me. Hopefully we’ll have a Rails 3 solution soon and I can add that to my developer series.

Note: We had an Appirio AppDev CoE call with Ben Scofield (Heroku’s developer advocate) last week and he suggested rolling a solution with OmniAuth. I think we are going to post a CloudSpokes contest to build this out for everyone.

So I decided to downgrade to an earlier version of Ruby and Rails so that I could use ActiveSalesforce for my developer series. I ended up (finally!) installing Ruby 1.8.7 and Rails 2.3.8 on a Ubuntu 10.10 VM. I think I could have used Ruby 1.9.2 but was caught in version hell. There are a couple of conflicting articles on how to setup your Rails environment (this one seems to be the best) but I finally got it working with a little help from the ActiveSalesforce Google Group.

Here are the steps that I went through on a fresh install of Ubuntu:

apt-get install ruby-full

wget production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz

tar -xvf rubygems-1.3.7.tgz

cd rubygems-1.3.7/

ruby setup.rb

ln -s /usr/bin/gem1.8 /usr/bin/gem

gem install rdoc

# install the 2.3.8 version of rails
gem install –version=2.3.8 rails –include-dependencies

# install sqlite dev lib
apt-get install libsqlite3-dev

# install rubygem
apt-get install rubygems

# install bundler
gem install Bundler

# install sqlite3
gem install sqlite3-ruby

# install rake
gem install rake

# install rforcedotcom
gem install rforcedotcom

# install the older version of facets for toolkit
gem install -v=2.8.4 facets

# install hpricot
gem install hpricot

# install the soap adapter
gem install asf-soap-adapter

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Categories: Ruby, Salesforce

Leave a comment

Comments Feed7 Comments

  1. Mike Leach

    Jeff- Thanks for your continued reporting from the bleeding edge!

    Would there be any benefit in simply using Rails with a Ruby SOAP wrapper to the Force web services API? Or is ActiveRecord a must-have pattern?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. Marina Martin

    I’ve been refreshing your blog multiple times a day in hopes you’d have found an elegant solution to the Rails 3 compatibility problem. I’m a huge Salesforce fan but so frustrated by the lack of Rails 3 resources; after spending $240 million on Heroku I’d think Salesforce could dedicate some resources to Rails! Quinton is fantastic but he’s just one person.

    Did you see that Raymond Gao just released asf-rest-adapter?

    Thanks for all your work on this; considering rewriting my existing apps in 2.3 (what a tremendous pain!) so I can actually use a SF gem.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. Jeff Douglas

    @Mike I honestly don’t know. I don’t have enough experience in Ruby yet.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  4. Jeff Douglas

    @Marina, I feel your pain rewriting your app in 2.3. I’m looking at doing the same but am contemplating riding out the storm. I’m looking at Raymond’s new alpha gem now but not sure if it will be done in time. I think another alternative is to just go the REST route. I think that will be the best solution in the longrun.

    VN:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  5. dan

    thanks for the write up and tips on connecting to salesforce via ruby. my work is using salesforce and im just getting started with ruby so i was thrilled to see someone posting tutorials on it.

    i was getting ready to go the REST way when i saw you link to salesforce about how to setup a dev environment. thanks again for the good info and i hope to hear some updates soon

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  6. Raymond Gao

    I guess I have been quite silent about this – Rails/Force. Personally, I think REST protocol is going to change the entire cloud-to-cloud integration. My point is more down the line of leveraging a Common Data Model, where people extend off a obust model, such as Force.com’s CRM, which has most of the objects. There is no need to reinvent the wheel and to recreate the schema from scratch, leading to incompatible and brittle apps.
    Of course, Rails 3 is causing a lot of changes.
    Please feel free to look at my wiki: http://wiki.are4.us and join the ‘activesalesforce’ group for discussing.
    As always, you guys are free to ping, should you need something.
    Ray, early experimenter of the Rails/Force.com platform.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  7. Raymond Gao

    typos, please change obust -> robust
    discussing -> discussions

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a comment

Feed

http://blog.jeffdouglas.com / Installing Ruby 1.8 and & 2.3.8 for ActiveSalesforce