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
41Falls41Falls 

asf-soap-adapter issue with Ruby On Rails 3.0.3

Hi everyone, Tried to test the integration between Salesforce.com and Ruby on Rails 3.0.3 (rubygem 1.5, ruby 1.9.2)
Content of database.yml (with proper credentials erased)
development:
    adapter: activesalesforce
    url: https://www.salesforce.com
    username: ######
    password: ######
    api_version: 20.0
test:
    adapter: activesalesforce
    url: https://www.salesforce.com
    username: #####
    password: #####
    api_version: 20.0
production:
    adapter: activesalesforce
    url: https://www.salesforce.com
    username: #####
    password: #####
    api_version: 20.0
    
salesforce-default-realm:
    adapter: activesalesforce
    url: https://www.salesforce.com
    username: #####
    password: #####
    api_version: 20.0

Then content of the gemfile file
...
gem 'rails', '3.0.3'

gem 'asf-soap-adapter', :require =>'activerecord-activesalesforce-adapter'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3-ruby', :require => 'sqlite3'

....
Runned a bundle install against this file, then a
rails generate model Salesforce::Contact
to get access to a standard SFDC object
When I try to use the console : rails console Everything load fine, no error and then when I type
Salesforce::Contact.first
After few seconds I get this error. Any clue ?
irb(main):015:0> Salesforce::Contact.first
ActiveSalesforce::ASFError: INVALID_TYPE: sObject type 'SalesforceContact__c' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.
from /usr/local/lib/ruby/gems/1.9.1/gems/asf-soap-adapter-1.1.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:665:in `get_result'
from /usr/local/lib/ruby/gems/1.9.1/gems/asf-soap-adapter-1.1.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:713:in `rescue in get_entity_def'
from /usr/local/lib/ruby/gems/1.9.1/gems/asf-soap-adapter-1.1.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:706:in `get_entity_def'
from /usr/local/lib/ruby/gems/1.9.1/gems/asf-soap-adapter-1.1.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:868:in `lookup'
from /usr/local/lib/ruby/gems/1.9.1/gems/asf-soap-adapter-1.1.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:329:in `select_all'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/base.rb:467:in `find_by_sql'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/relation.rb:64:in `to_a'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:333:in `find_first'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:122:in `first'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/base.rb:439:in `first'
from (irb):15
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Tried also with a custom object called Test1, generated also the model and I get this
irb(main):016:0> Salesforce::Test1.first
ActiveSalesforce::ASFError: MALFORMED_QUERY: \nSELECT  Test1__c.* FROM Test1__c LIMIT 1\n                ^\nERROR at Row:1:Column:17\nunexpected token: '*'
from /usr/local/lib/ruby/gems/1.9.1/gems/asf-soap-adapter-1.1.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:665:in `get_result'
from /usr/local/lib/ruby/gems/1.9.1/gems/asf-soap-adapter-1.1.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:384:in `select_all'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/base.rb:467:in `find_by_sql'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/relation.rb:64:in `to_a'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:333:in `find_first'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:122:in `first'
from /usr/local/lib/ruby/gems/1.9.1/gems/activerecord-3.0.3/lib/active_record/base.rb:439:in `first'
from (irb):16
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Thanks in advance
For information here is the list of gems when I try to list them, what is weird is that I can't see the activerecord-activesalesforce-adapter gem even though it is listed in the Gemfile
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.3) 
Using builder (2.1.2) 
Using i18n (0.5.0) 
Using activemodel (3.0.3) 
Using erubis (2.6.6) 
Using rack (1.2.1) 
Using rack-mount (0.6.13) 
Using rack-test (0.5.7) 
Using tzinfo (0.3.24) 
Using actionpack (3.0.3) 
Using mime-types (1.16) 
Using polyglot (0.3.1) 
Using treetop (1.4.9) 
Using mail (2.2.15) 
Using actionmailer (3.0.3) 
Using arel (2.0.7) 
Using activerecord (3.0.3) 
Using activeresource (3.0.3) 
Using facets (2.8.4) 
Using hpricot (0.8.3) 
Using oauth (0.4.4) 
Using rforce (0.6) 
Using asf-soap-adapter (1.1.0) 
Using bundler (1.0.10) 
Using thor (0.14.6) 
Using railties (3.0.3) 
Using rails (3.0.3) 
Using sqlite3 (1.3.3) 
Using sqlite3-ruby (1.3.3) 
cloudcodercloudcoder

First quick point, the current adapter was written for rails 2.3.x, but, in theory, it should work for v3.

 

Looking at your snippet, you are trying to generate a model on an existing Salesforce object, which is basically trying to create a custom object, thus the __c suffix.

 

Long story short, you don't need to generate models for standard objects. eg: something like the following will work just fine from the console:

 

>> Salesforce::Contact.first

 

Creating custom objects should work fine:

 

script/generate model Salesforce::CustomObject

 

Just remember you dont need to add the __c as the adapter will take care of it.

 

HTH

 

41Falls41Falls

Thanks for your answer, but unfortunately it doesn't seem to work with Rails 3, I have rebuild an entire project using the same configuration files and gemfile In the console I get this (didn't generate any model)

 

irb(main): Salesforce::Contact.first

NameError: uninitialized constant Salesforce

  from (irb):1

  from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'

  from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'

  from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:23:in `'

  from script/rails:6:in `require' from script/rails:6:in `'

cloudcodercloudcoder

I'll try and get some time today to build a project in Rails 3 and confirm, but the toolkit was build for v2.3.x. I'll give it a whirl.

 

FYI I am working on the toolkit specs for Rails 3 today :)

 

 

cloudcodercloudcoder

Sorry, I forgot to add that you could always use the REST API to connect pretty easily now.

 

See http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-ruby

41Falls41Falls

Thanks Cloud for your answer, please keep me updated on this.

Started also to investigate the REST API, but... it is pretty verbose compared to the asf-soap-adapter.

 

cloudcodercloudcoder

yepper. stay tuned on the update to the toolkit.

ybakosybakos

Quinton, what ever happened to the creation of a Rails 3.0.3 (or 3.0.4) with the forcedotcom and asf-soap-adapter gems?

 

cloudcodercloudcoder

Good timing. I am actually writing some info about it as we speak to make sure we gather the correct requirements. I have also been working with the Heroku folks to ensure we leverage their experience too. Writing the toolkit is certainly very high on my todo list.

 

One thing to note is that the toolkit will use REST and move away from the active-record model.

 

Best I can add right now re ETA is as soon as I can. I know it is very important to the Ruby community, but we want to do it right

ybakosybakos

You said all the magic words. Thanks for your efforts behind Rails/Salesforce integration.

 

However, my question remains: is there no working toolkit (gem) for Rails 3.x integration with SF?

 

For other readers, here's another relevant forum thread.

 

 

cloudcodercloudcoder

You are correct. I am working hard to rectify this as quickly as I can.

patrick.bulaczpatrick.bulacz

Hey guys,

 

Any update on this? I got part way through starting before I found these posts and realised the force.com 'toolkit' doesn't comply for ruby on rails 3.0+