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
KunjanKunjan 

Communication of Ruby on Rail with Salesforce

Hi,


Does anyone know how to build ruby on rails and salesforce mashup projects?
Please let me know what tools are necessary and easiest way to install Ruby as I am new for Ruby and how to communicate it using Salesforce.

If any one can guide me in the proper way that would be highly appreciated.


Thanks
Kunjan

joshbirkjoshbirk

Here's a wiki page on using the current (recently released) Ruby toolkit:

 

http://wiki.developerforce.com/index.php/Getting_Started_with_the_Force.com_Toolkit_for_Ruby

 

As well as a recent blog post on getting the environment up and running:

 

http://blog.sforce.com/sforce/2010/12/setting-up-your-ruby-on-rails-environment-for-forcecom-.html

 

 

KunjanKunjan

The links which you have provided are quite enough for Standard objects and it works fine with account & contact objects.

I want to execute scaffold command for custom object, but the generated pages are not establishing connection with salesforce rather it tries to connect with local mysql database.

 

The same database.yml file works with standard object but not for custom object.

 

Please give me right direction for above issue.

 

Thanks in advance,

Kunjan

 

joshbirkjoshbirk

That seems odd - what is the name of the custom object you're trying to access?

 

Did you make any updates to the custom object model in Ruby?

KunjanKunjan

No, I didn't made any changes in custom object model.

I have just installed asf-soap-adapter of Ruby Force.com toolkit.

 

Name of my custom object: TestObj

 

 

joshbirkjoshbirk

There's a section in the wiki article on updating custom objects, which is oddly not cutting and pasting for me right now.  Basically it needs to extend the SfBase and set the table name, however.

 

 

 

 

cloudcodercloudcoder

Josh is correct. Just remember you don't need the __c:

 

 

script/generate model Salesforce::CustomObject
And update the resulting model file to run set_table_name:
class CustomObject < SfBase     
  set_table_name ‘CustomObject’  
  # must be a valid Salesforce Table, otherwise, it will complain.   
end

 

KunjanKunjan

I made chances in model file, but now it's throwing error like:

Anonymous modules have no name to be referenced by

 

Please help me to solve this issue.

 

Thanks,

- Kunjan

KunjanKunjan

It seems like model file was inherited by SfBase class and due to that eror was generaetd.

 

But can you please tell me how to access custom fields of standard and custom object?

 

I am getting following error while accessing custom field of custom object.

undefined method `VisitDate' for #<Salesforce::VisitorReport:0x2986140>

where VisitDate is my custom field and VisitorReport is my custom object.

 

Thanks,

- Kunjan

cloudcodercloudcoder

Does your Salesforce org already have the Custom object? You can not currently create a model from ruby and do a rake db:migrate to create it in Salesforce. This is certainly something we want to add in newer versions of the toolkit but there are a number of dependencies to making this happen.

KunjanKunjan

The custom object is already exist in my salesforce org. Even the same error I am getting with custom fields of standard object. So is it possible to use/get custom fields of standard/custom object?

 

- Kunjan