Display salesforce.com account listing with Ruby on Rails
I would like to show you, how I did my first connection from Rails to salesforce.com. As an example I would like to display a listing of salesforce.com accounts on a web page.
Getting Started
Following the instructions on ActiveSalesforce (ASF) I installed ActiveSalesforce gem, created a Rails application and configured the application and database.
D:\projects>gem install activesalesforce --include-dependencies
D:\projects>rails sftest
D:\projects>cd sftest
Edit D:\projects\sftest\config\environment.rb and add the line require_gem 'activesalesforce'. If you forget to require the gem you will get an error message: database configuration specifies nonexistent activesalesforce adapter (ActiveRecord::AdapterNotFound).
Edit D:\projects\sftest\config\database.yml and add your salesforce.com account information.
adapter: activesalesforce
url: https://www.salesforce.com/services/Soap/u/7.0
username: salesforce-username
password: salesforce-passwordCreate module and controller.
D:\projects\sftest>ruby script/generate model account
D:\projects\sftest>ruby script/generate controller account
Edit D:\projects\sftest\app\controllers\account_controller.rb.
class AccountController < ApplicationController
scaffold :account
endRun the server and watch the result in your browser.
D:\projects\sftest>ruby sript/server

Resources
technorati tags:rubyonrails, rails, activesalesforce, salesforce
3 Comments:
Can I do the same if I used the API of other crm companies such Salesboom.com or Netsuite?
Rails uses ActiveRecord to connect to data sources and provide a mapping of relational data to Ruby objects.
To connect to a specific data source, ActiveRecord needs an adapter. In case of Salesforce.com the adapter implementation is ActiveSalesforce.
To connect to other CRM systems with Rails you need a ActiveRecord::ConnectionAdapter for your CRM system of choice (see Rails API ActiveRecord::ConnectionAdapters::AbstractAdapter).
hey hi,
I am using ruby salesforce api for quite a while. For some of my existing customers, I keep getting this weird error saying "Column Not Found for meta!".
However, I am not able to replicate this error. but one of the customer said, when he cleared the cookies, he is not getting the error.. and he is not even able to replicate again.
Can you help me in understanding what might be going wrong ?
Error: Column not found for meta! /var/lib/gems/1.8/gems/activerecord-activesalesforce-adapter-2.0.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:528:in `get_fields'/var/rails/website/current/vendor/rails/activesupport/lib/active_support/inflector.rb:257:in `each_with_index'/var/lib/gems/1.8/gems/activerecord-activesalesforce-adapter-2.0.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:522:in `each'/var/lib/gems/1.8/gems/activerecord-activesalesforce-adapter-2.0.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:522:in `each_with_index'/var/lib/gems/1.8/gems/activerecord-activesalesforce-adapter-2.0.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:522:in `get_fields'/var/lib/gems/1.8/gems/activerecord-activesalesforce-adapter-2.0.0/lib/active_record/connection_adapters/activesalesforce_adapter.rb:417:in `update'/var/rails/website/current/vendor/rails/activerecord/lib/active_record/base.rb:2247:in `update_without_lock'/var/rails/website/current/vendor/rails/activerecord/lib/active_record/locking/optimistic.rb:70:in `update_without_callbacks'/var/rails/website/current/vendor/rails/activerecord/lib/active_record/callbacks.rb:240:in `update_without_timestamps'/var/rails/website/current/vendor/rails/activerecord/lib/active_record/timestamp.rb:38:
Post a Comment
Links to this post:
Create a Link