function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ybakosybakos 

Rails 3.0.3/4 and proper documentation (frustrated)

First, thanks for any help from the community and to Quinton for his development efforts, I am grateful.

 

I'm writing to express my frustration at what seems to me to be prolific yet out of date and conflicting documentation regarding SalesForce and Rails integration.

 

Is the "force.com toolkit for ruby" the rforcedotcom gem?

 

As of today, should developers be using activesalesforce, activerecord-salesforce-adapter, or asf-soap-adapter?

 

I haven't been able to accomplish my simple goal: creating a Rails 3.0.4 application that allows me to execute, from the console, Salesforce::SfBase.query_by_sql("select name from Account")

 

rails new someapp

cd someapp

bundle install

script/console

(explosion)

 

Given that my Gemfile states:

 

source 'http://rubygems.org'

gem 'rails', '3.0.4'
gem 'sqlite3'
gem 'asf-soap-adapter'

 

 

And my database.yml states:

 

development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

salesforce-default-realm:
  adapter: activesalesforce
  url: https://www.salesforce.com
  username: xxx
  password: xxx
  api_version: 20.0

 And my current gemset includes only the following:

 

abstract (1.0.0)
actionmailer (3.0.4)
actionpack (3.0.4)
activemodel (3.0.4)
activerecord (3.0.4)
activerecord-activesalesforce-adapter (2.0.0)
activeresource (3.0.4)
activesalesforce (1.1.6)
activesupport (3.0.4)
arel (2.0.8)
asf-soap-adapter (1.3.0)
builder (2.1.2)
bundler (1.0.10)
erubis (2.6.6)
facets (2.8.4)
hpricot (0.8.3)
i18n (0.5.0)
mail (2.2.15)
mime-types (1.16)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.7)
rails (3.0.4)
railties (3.0.4)
rake (0.8.7)
rforcedotcom (20.0.0)
sqlite3 (1.3.3)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.24)

 

 

This should freakin' work. But it doesn't. Upon executing rails console:

 

/Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/activerecord-3.0.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection': salesforce-default-realm database is not configured (ActiveRecord::AdapterNotSpecified)
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/asf-soap-adapter-1.3.0/lib/salesforce/sf_base.rb:61
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/asf-soap-adapter-1.3.0/lib/asf-soap-adapter.rb:4:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/asf-soap-adapter-1.3.0/lib/asf-soap-adapter.rb:4
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
	from /Users/ybakos/tmp/sftest02/config/application.rb:7
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/railties-3.0.4/lib/rails/commands.rb:21:in `require'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@test/gems/railties-3.0.4/lib/rails/commands.rb:21
	from script/rails:6:in `require'
	from script/rails:6

 

If anyone has successfully created a skeletal Rails 3.x app and has been able to fire up the console and execute Salesforce::SfBase.query_by_sql("select name from Account")

 


Then please do share what steps you took, and what your Gemfile and database.yml state.

 

cloudcodercloudcoder

Thanks for the support, and yes I agree there has been some fragmentation. One of the reasons for the rforcedotcom gem is that it means that Saleforce could update the get with new API versions much easier. A lot of the frustration you indicated comes from a bunch of different community groups working diligently to fill a need. I am meeting with some of the lead community members in NYC at the start of March to address some of your concerns for rails v2+ apps.

 

Rails v3, on the other hand, is another story. We have the opportunity to do it right from a code and community perspective. This starts with a good REST implementation and moving away from active-record. I am SUPER excited to work on that and fully to make it very much a community driven project - one of the things I love about Ruby is the passionate community. 

 

Stay tuned, and I certainly appreciate your feedback!

cloudcodercloudcoder

btw,

 

try the following in your yml file:

 

 

 common: &common
   adapter: activesalesforce
   username: my@email.com
   password: passwordTOKEN
   api_version: 20.0
 
   development:
 <<: *common
salesforce-default-realm:
    <<: *common

 

ybakosybakos

Thanks for the feedback regarding my app config.

 

Upon executing

 

Salesforce::SfBase.query_by_sql("select name from Account")

 

I still receive the same error from the console:

 

NameError: uninitialized constant Salesforce::SfBase

 

 

Has anyone gotten this to work w/ Rails 3.0.3/4 ?

naveenkumarbvnaveenkumarbv

Hi All,

 

    Can anyone help me in integrating Rails3.0.3/Ruby1.9.2 with salesforce.

 

@ybakos

   

              Looks like you and me are facing the same problem. I'm also confused as to which gem to use among activesalesforceactiverecord-salesforce-adapter, or asf-soap-adapter and get it working.

Can you help me regarding this if you find any solution.

ybakosybakos

Naveen, there is no current solution apparently.

 

cloudcodercloudcoder

FYI, you may want to try taking the following gem for a spin. It is still alpha, but some with strong heritage - Ray updated the active-salesforce adapter to v20, which became the current Force.com for Ruby toolkit.

 

https://rubygems.org/gems/asf-rest-adapter

 

I would love to here how it goes.

 

Q

 

ybakosybakos

Thanks Quinton (and Raymond!), that's exciting and I'll try it asap.

ybakosybakos

I'm really appreciative of the work behind the restful gem. However, the lingering asf-soap-adapter dependency seems to mean we still don't have compatibility with Rails 3.x.

 

I'm seeing the same error with the restful gem that I've seen with the soap gem:

 

 

ruby-1.8.7-p330 :001 > Salesforce::Rest::AsfRest.bootup_rest_adapter
"********************************************************************************"
"Set up code"
ArgumentError: method does not exist
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/facets-2.8.4/lib/core/facets/module/redefine_method.rb:27:in `redefine_method'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/associations.rb:1445:in `association_accessor_methods'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/associations.rb:1225:in `belongs_to'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/autosave_association.rb:137:in `belongs_to'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/asf-soap-adapter-1.3.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:802:in `configure_active_record'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/asf-soap-adapter-1.3.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:764:in `each'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/asf-soap-adapter-1.3.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:764:in `configure_active_record'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/asf-soap-adapter-1.3.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:741:in `get_entity_def'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/asf-soap-adapter-1.3.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:865:in `lookup'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/asf-soap-adapter-1.3.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:326:in `select_all'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/base.rb:467:in `find_by_sql'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/relation.rb:64:in `to_a'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/relation/finder_methods.rb:333:in `find_first'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/relation/finder_methods.rb:122:in `first'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/base.rb:439:in `__send__'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/activerecord-3.0.4/lib/active_record/base.rb:439:in `first'
	from /Users/ybakos/.rvm/gems/ruby-1.8.7-p330@pcwi_sf_rails3/gems/asf-rest-adapter-0.1.5/lib/salesforce/rest/asf_rest.rb:58:in `bootup_rest_adapter'

 

 

cloudcodercloudcoder

FYI, I just finished an omniauth+httparty+rails3 sample which should make your life much easier. I am writing it up now and will post to blog.sforce.com as soon as the guide is done.

 

HTH

naveenkumarbvnaveenkumarbv

Hi Quinton,

 

     Good to see that there are new implementations coming up to integrate with Rails 3.

 

I found that RESTful API would be the defacto standard to communicate with salesforce if we are using Rails 3.x.

 

 

And, we need to authenticate to salesforce using OAuth and then use the REST API to perform further operations.

How do I ensure that REST API is enabled for my developer account, because I am not able to view the REST explorer when I login using my developer account credentials?

 

Regards,

Naveen Kumar B.V

naveenkumarbvnaveenkumarbv

And I am not able to register for a REST api using the following link given in forums:

https://www.developerforce.com/events/rest_developer_preview/registration.php 

 

because it is getting redirected to another link: http://developer.force.com/REST.

 

Can you help me in finding out how to register for REST api using a Developer Edition(DE) account.

 

Regards,

Naveen Kumar B.V

cloudcodercloudcoder

As of Spring 11, the REST API is now GA. There is no need to register, all orgs are enabled.