I am using the Ruby Gem “Databasedotcom” to integrate Salesforce in a Rails app and all works fine, but I now facing a problem with the same object name in the Rails application and Salesforce.
I have a User model in my Rails application and User object is also in Salesforce. So when trying to get data from Salesforce User object it always return the Rails application User object.
Here is my code
client = Databasedotcom::Client.new
client.client_id #=> foo
client.client_secret #=> bar
client.authenticate :username => "foo@bar.com", :password => "ThePasswordTheSecurityToken" #=> "the-oauth-token"
client.materialize("User");
@user = User.find_by_Id('005d0000001291x');
but above statement always use the User model from Rails.
I want to use the Salesforce User object to get its data.
Thanks for any help.
At first wrap up you SF code in a module like this:
And create initializer where you specify module to use with
sobject_moduleparam:config/salesforce.yml:
Add initializer to config/initializers:
salesforce.rb:
Now you can use User inside SF module and it will be SF User, not you AR one.
And also I highly recommend you to read the documentation, there are quite a lot methods that will help you make your SF code cleaner:
http://rubydoc.info/github/heroku/databasedotcom/master/frames
Good luck with SF!