+ Start a Discussion
Skip KSkip K 

ruby on rails integrated with salesforce

I'm new to salesforce and ruby. Is there a helloworld tutorial that someone could point me to? I'm having trouble with the configuration in rails to make the connection to salesforce

 

I have installed:

ruby 1.9.3p125 (2012-02-16) [i386-mingw32]

Rails 3.2.1

 

Thanks!


Skip

Best Answer chosen by Admin (Salesforce Developers) 
Skip KSkip K

I figured it out. I had to add this line to my databasedotcom.yml:

verify_mode: OpenSSL::SSL::VERIFY_NONE
It looks like starting with ruby 1.9.2, verify_mode defualts to VERIFY_PEER.
Some further explantion can be found here:

https://groups.google.com/group/activesalesforce/browse_thread/thread/40a06f8444bcada5/800c3487feb68cb7?lnk=raot&pli=1

 

Thanks to all who pitched in.

All Answers

Software Allies TeamSoftware Allies Team

Skip,

 

There are many options to integrate a rails project with Salesforce. However using an already written gem might be easier. 

 

Here is one we wrote.

 

Salesforce Bulk Gem:

http://rubygems.org/gems/salesforce_bulk

 

Instructions

http://rubydoc.info/gems/salesforce_bulk/0.0.5/frames

 

You might also want to check out the databasedotcom gem if you don't need bulk operations.

 

Thanks,

 

Jason Stafford

Software Allies

http://www.softwareallies.com

Skip KSkip K

Thanks for the reply. I'm currently using the databasedotcom gem as called for in this tutorial:

http://techblog.appirio.com/2012/01/tutorial-getting-started-with-rails.html

 

Any idea on setup, either on salesforce or rails that I need to implement?

 

I have a databasedotcom.yml that looks like this:

host: login.salesforce.com
client_secret: <client secret>

client_id: <client key>
debugging: true
username: reuel3@gmail.com

password: <password with secure token>

 

There was really no other configuration suggested.

Can I use those instructions for this gem too, or is there another that you could point me to?

 

Any help is appreciated as I've been stuck on this for too long.

 

Thanks,

Skip

Software Allies TeamSoftware Allies Team

Skip,

 

 

First you need to add databasedotcom to your gemfile

 

gem 'databasedotcom'
If you using rails, you should include the rails gem for databasedotcom also
gem 'databasedotcom-rails'
After this be sure to run:
bundle install
Next:
You to actually build something in rails that will use this resource, create a model for it:
rails generate scaffold_controller Lead FirstName:String LastName:String

Then jump over to Salesforce and add in the remote site for access
Go to Setup -> Develop -> Remote Access -> New
You should be able to put in the hostname or IP address for you rails server, if you are using Heroku, then you will  need to enter the address for you app.
When you get all this setup, then you can look at your yml config for databaasedotcom
your might have to change your host name to test.salesforce.com if you are using your sandbox.
Thanks,
Jason Stafford
Software Allies

Skip KSkip K

I've done all of that and I'm still getting an error. Is there something I need to do in sf to allow access? I think it may have something to do with password. I'm entering passwordtoken where my password is the one I use to login to sf.

 

I'm running out of ideas.

Skip KSkip K

More info. This is what I get when trying to connect to sf.

I'm also using rails 3.2.3 now.

 

I'm begging for help!


Started GET "/" for 127.0.0.1 at 2012-05-14 13:48:11 -0400
Processing by AccountsController#index as HTML
Completed 500 Internal Server Error in 89ms

OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=SSLv3 read server c
ertificate B: certificate verify failed):
app/controllers/accounts_controller.rb:6:in `index'


Rendered c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.3
/lib/action_dispatch/middleware/templates/rescues/_trace.erb (4.0ms)
Rendered c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.3
/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (2.0
ms)
Rendered c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.3
/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues
/layout (279.0ms)
[2012-05-14 13:48:18] WARN Could not determine content-length of response body.
Set content-length of the response or set Response#chunked = true

woodmanzwoodmanz

Skip - I just had this same problem, there's not much documentation out there!

Luckily I got my app up and running, and I wrote a little blog post about some handy steps and other gems to use. The last link provided in the post is a good link to a solution that has working authentication - you might want to fork their github repo. Here's the post:

http://blog.touchpointcrm.com/2012/05/building-a-mobile-rails-app-with-salesforce/

 

let me know if you have any specific questions, I'll see what I can do

Skip KSkip K

Thanks for the reply! I was afraid no one was out there.

 

What did you change to get around the ssl issue? In the tutorial I'm working through it said that it didn't use ssl but I couldn't figure out how to call it using just http. I would like to understand how to get it to work with and without ssl.

 

Thanks for your help,

Skip

Skip KSkip K

I figured it out. I had to add this line to my databasedotcom.yml:

verify_mode: OpenSSL::SSL::VERIFY_NONE
It looks like starting with ruby 1.9.2, verify_mode defualts to VERIFY_PEER.
Some further explantion can be found here:

https://groups.google.com/group/activesalesforce/browse_thread/thread/40a06f8444bcada5/800c3487feb68cb7?lnk=raot&pli=1

 

Thanks to all who pitched in.

This was selected as the best answer