<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DkMCSXo4cSp7ImA9WhVUGUs.&quot;"><id>tag:blogger.com,1999:blog-6747272934569803137</id><updated>2012-05-25T09:47:48.439-07:00</updated><category term="Python" /><category term="Talend" /><category term="Google Maps" /><category term="Appirio" /><category term="DanGuggenheim" /><category term="GoogleGO" /><category term="Contest" /><category term="OAuth" /><category term="Force.com" /><category term="KyleRoche" /><category term="Cache" /><category term="Twilio" /><category term="CNAME" /><category term="Google Docs" /><category term="gwt" /><category term="competition" /><category term="Auto Number" /><category term="Google COE" /><category term="TimParker" /><category term="Azure" /><category term="CustomerPortal" /><category term="LindaEvans" /><category term="ChrisBruzzi" /><category term="Salesforce.com" /><category term="FrankHansen" /><category term="DanArrigan" /><category term="Flex" /><category term="Single Sign-On" /><category term="Tech Blog" /><category term="Chatter" /><category term="Android" /><category term="Google I/O" /><category term="Facebook" /><category term="Jason Ouellette" /><category term="Cloud" /><category term="Heroku" /><category term="Content" /><category term="Girafa" /><category term="Sites" /><category term="VMforce" /><category term="CSS" /><category term="Google Wave" /><category term="REST" /><category term="GlennWeinstein" /><category term="vmware" /><category term="Visualforce" /><category term="Developer Community" /><category term="Workflow" /><category term="MichaelMcLaughlin" /><category term="WardLoving" /><category term="Visual Force" /><category term="OpenID" /><category term="Blog Update" /><category term="Dynamic APEX" /><category term="Google Chrome" /><category term="Winter 11" /><category term="Apex" /><category term="JeffDouglas" /><category term="Ruby" /><category term="Django" /><category term="Java App Engine" /><category term="WillSupinski" /><category term="MattPruden" /><category term="Google Sidebar Gadgets" /><category term="AndreaGiometti" /><category term="TimGarthwaite" /><category term="Summer 11" /><category term="KyleFreeman" /><category term="Appengine" /><category term="Google Apps" /><title>Appirio Tech Blog</title><subtitle type="html">Cool technical tips and code samples for salesforce.com, Google, on-demand software, and other technical topics.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://techblog.appirio.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://techblog.appirio.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/6747272934569803137/posts/default?start-index=4&amp;max-results=3&amp;redirect=false&amp;v=2" /><author><name>Appirio</name><uri>http://www.blogger.com/profile/15774523927536637030</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>83</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>3</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/appiriotechblog" /><feedburner:info uri="appiriotechblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>appiriotechblog</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry gd:etag="W/&quot;DEcNQ384eCp7ImA9WhRUF0g.&quot;"><id>tag:blogger.com,1999:blog-6747272934569803137.post-8395054038719366303</id><published>2012-01-28T05:07:00.000-08:00</published><updated>2012-01-28T05:08:12.130-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-28T05:08:12.130-08:00</app:edited><title>Tutorial - Getting Started with Rails &amp; Databasedotcom Gem</title><content type="html">&lt;br /&gt;
It the new year again and time for resolutions. I made a resolution about a year ago to learn ruby. If you are looking for something to learn this year I would recommend ruby and here’s why:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Salesforce.com bought Heroku for $220M&lt;/li&gt;
&lt;li&gt;Salesforce.com has been pushing “Open. Social. Mobile” for quite some time.&lt;/li&gt;
&lt;li&gt;Ruby is great for creating social and mobile apps with open source technologies.&lt;/li&gt;
&lt;/ul&gt;
Do you see a correlation here? There are big things ahead for Force.com developers using Heroku. Eventhough Heroku is a &lt;a href="http://blog.heroku.com/archives/2011/8/3/polyglot_platform/" target="_blank"&gt;polyglot platform&lt;/a&gt;, it shines with ruby. If you have the time, add ruby to your toolbox.&lt;br /&gt;
&lt;br /&gt;
I presented this topic today at our Appirio Continuing Education webinar and thought it might come in handy for others trying to learn ruby. In the video I use the Databasedotcom gem to build a small app that displays a list of accounts, the details for a selected account and then queries for accounts by keyword. I reference some links to help you get started with ruby and rails and I’ve added them after the video.&lt;br /&gt;
&lt;br /&gt;
You can find the source code &lt;a href="https://github.com/jeffdonthemic/Databasedotcom-Gem-Demo" target="_blank"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://3.gvt0.com/vi/_jWUOn8z-UM/0.jpg" height="284" width="500"&gt;&lt;param name="movie" value="http://www.youtube.com/v/_jWUOn8z-UM&amp;fs=1&amp;source=uds" /&gt;




&lt;param name="bgcolor" value="#FFFFFF" /&gt;




&lt;embed width="500" height="284"  src="http://www.youtube.com/v/_jWUOn8z-UM&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Links Referenced in the Video&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://www.railsinstaller.org/"&gt;Railsnstaller&lt;/a&gt; (Windows)&lt;br /&gt;
&lt;a href="http://mxcl.github.com/homebrew"&gt;Homebrew&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://beginrescueend.com/"&gt;Ruby Version Manager (RVM)&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://guides.rubyonrails.org/getting_started.html"&gt;Rails Guides&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://www.railscasts.com/"&gt;Railscasts&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://railsforzombies.com/"&gt;Rails for Zombies&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://www.codeschool.com/"&gt;Code School&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://www.codeschool.com/courses/try-ruby"&gt;Try Ruby&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://ruby.railstutorial.org/"&gt;Ruby on Rails Tutorial&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://api.rubyonrails.org/"&gt;Ruby on Rails Documentation&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://github.com/heroku/databasedotcom"&gt;Databasedotcom gem&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://www.youtube.com/watch?v=7zeGJLXd600"&gt;Building and Deploying Great Applications with Salesforce, Ruby, and Heroku&lt;/a&gt; (Dreamforce)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6747272934569803137-8395054038719366303?l=techblog.appirio.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=Rl-ESw_axuA:PJNzviHZkzg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=Rl-ESw_axuA:PJNzviHZkzg:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?i=Rl-ESw_axuA:PJNzviHZkzg:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=Rl-ESw_axuA:PJNzviHZkzg:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?i=Rl-ESw_axuA:PJNzviHZkzg:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=Rl-ESw_axuA:PJNzviHZkzg:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/appiriotechblog/~4/Rl-ESw_axuA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://techblog.appirio.com/feeds/8395054038719366303/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techblog.appirio.com/2012/01/tutorial-getting-started-with-rails.html#comment-form" title="17 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6747272934569803137/posts/default/8395054038719366303?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6747272934569803137/posts/default/8395054038719366303?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/appiriotechblog/~3/Rl-ESw_axuA/tutorial-getting-started-with-rails.html" title="Tutorial - Getting Started with Rails &amp; Databasedotcom Gem" /><author><name>Jeff Douglas</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-yH6OXRZAHQc/AAAAAAAAAAI/AAAAAAAAAUs/YNIXfF_sEE4/s512-c/photo.jpg" /></author><thr:total>17</thr:total><feedburner:origLink>http://techblog.appirio.com/2012/01/tutorial-getting-started-with-rails.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EBSX47cSp7ImA9WhdUE0Q.&quot;"><id>tag:blogger.com,1999:blog-6747272934569803137.post-8044732464089529301</id><published>2011-09-30T09:20:00.000-07:00</published><updated>2011-09-30T09:20:58.009-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-09-30T09:20:58.009-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="REST" /><category scheme="http://www.blogger.com/atom/ns#" term="Salesforce.com" /><title>Make Any Salesforce sObject REST-enabled</title><content type="html">&lt;br /&gt;
One of our #awesome guys, George Acker, created this nifty process to REST-enable any sObject in salesforce.com.&lt;br /&gt;
&lt;br /&gt;
It's a little hard to watch in this small window. You might want to view it full screen &lt;a href="http://www.screencast.com/t/UwAfYc0HP"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;object data="http://content.screencast.com/users/CloudSpokes/folders/Default/media/3180f941-5e28-449e-af8f-c97cbba9ddc4/bootstrap.swf" height="253" id="scPlayer" type="application/x-shockwave-flash" width="500"&gt; &lt;param name="movie" value="http://content.screencast.com/users/CloudSpokes/folders/Default/media/3180f941-5e28-449e-af8f-c97cbba9ddc4/bootstrap.swf" /&gt;
 &lt;param name="quality" value="high" /&gt;
 &lt;param name="bgcolor" value="#FFFFFF" /&gt;
 &lt;param name="flashVars" value="thumb=http://content.screencast.com/users/CloudSpokes/folders/Default/media/3180f941-5e28-449e-af8f-c97cbba9ddc4/FirstFrame.jpg&amp;containerwidth=500&amp;containerheight=253&amp;content=http://content.screencast.com/users/CloudSpokes/folders/Default/media/3180f941-5e28-449e-af8f-c97cbba9ddc4/GenericRESTDemo.swf&amp;blurover=false" /&gt;
 &lt;param name="allowFullScreen" value="true" /&gt;
 &lt;param name="scale" value="showall" /&gt;
 &lt;param name="allowScriptAccess" value="always" /&gt;
 &lt;param name="base" value="http://content.screencast.com/users/CloudSpokes/folders/Default/media/3180f941-5e28-449e-af8f-c97cbba9ddc4/" /&gt;
 Unable to display content. Adobe Flash is required.&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6747272934569803137-8044732464089529301?l=techblog.appirio.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=ck9IZ87XO1w:ee1p4HdGgrU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=ck9IZ87XO1w:ee1p4HdGgrU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?i=ck9IZ87XO1w:ee1p4HdGgrU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=ck9IZ87XO1w:ee1p4HdGgrU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?i=ck9IZ87XO1w:ee1p4HdGgrU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=ck9IZ87XO1w:ee1p4HdGgrU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/appiriotechblog/~4/ck9IZ87XO1w" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://techblog.appirio.com/feeds/8044732464089529301/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techblog.appirio.com/2011/09/make-any-salesforce-sobject-rest.html#comment-form" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6747272934569803137/posts/default/8044732464089529301?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6747272934569803137/posts/default/8044732464089529301?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/appiriotechblog/~3/ck9IZ87XO1w/make-any-salesforce-sobject-rest.html" title="Make Any Salesforce sObject REST-enabled" /><author><name>Jeff Douglas</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-yH6OXRZAHQc/AAAAAAAAAAI/AAAAAAAAAUs/YNIXfF_sEE4/s512-c/photo.jpg" /></author><thr:total>5</thr:total><feedburner:origLink>http://techblog.appirio.com/2011/09/make-any-salesforce-sobject-rest.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcHRH88eip7ImA9WhZUEEQ.&quot;"><id>tag:blogger.com,1999:blog-6747272934569803137.post-1825235569855116922</id><published>2011-06-03T03:47:00.000-07:00</published><updated>2011-06-03T03:47:15.172-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-03T03:47:15.172-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JeffDouglas" /><category scheme="http://www.blogger.com/atom/ns#" term="Heroku" /><category scheme="http://www.blogger.com/atom/ns#" term="Ruby" /><title>Demo App - Ruby, Rails &amp; Force.com REST API on Heroku</title><content type="html">&lt;a href="http://blog.jeffdouglas.com/wp-content/uploads/2011/05/ruby.png" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"&gt;&lt;img alt="" class="alignleft size-thumbnail wp-image-3927" height="150" src="http://blog.jeffdouglas.com/wp-content/uploads/2011/05/ruby-150x150.png" title="ruby" width="150" /&gt;&lt;/a&gt;So continuing with my &lt;a href="http://blog.jeffdouglas.com/category/ruby/"&gt;learning Ruby series&lt;/a&gt;, I finally finished my sample app using the Force.com REST API. I ran into a &lt;a href="http://boards.developerforce.com/t5/Perl-PHP-Python-Ruby-Development/Heroku-Crash-No-such-file-to-load-Accounts/td-p/275949"&gt;few issues&lt;/a&gt; and fortunately &lt;a href="http://twitter.com/quintonwall"&gt;Quinton Wall&lt;/a&gt; and Heroku support came to my rescue. Apparently &lt;em&gt;require 'Accounts'&lt;/em&gt; and &lt;em&gt;require 'accounts'&lt;/em&gt; aren't the same when running on Heroku. Go figure.&lt;br /&gt;
&lt;br /&gt;
This is a demo Rails app running on Ruby 1.9.2 and Rails 3.0.5 hosted on Heroku. It uses OAuth2 via &lt;a href="https://github.com/intridea/omniauth"&gt;OmniAuth&lt;/a&gt;  to authorize access to a salesforce.com org. It uses the &lt;a href="http://wiki.developerforce.com/index.php/Getting_Started_with_the_Force.com_REST_API"&gt;Force.com REST API&lt;/a&gt; to query for records, retreive records to display, create new records and update existing ones. It should be good sample app to get noobs (like me) up and running.&lt;br /&gt;
&lt;br /&gt;
I forked Quinton Wall's (excellent) &lt;a href="https://github.com/quintonwall/omniauth-rails3-forcedotcom/wiki/Build-Mobile-Apps-in-the-Cloud-with-Omniauth,-Httparty-and-Force.com"&gt;omniauth-rails3-forcedotcom project&lt;/a&gt; to get started. One of the things you have to do when using the Force.com REST API is to configure your server to run under SSL using WEBrick. I found some excellent instruction for OS X &lt;a href="http://www.nearinfinity.com/blogs/chris_rohr/configuring_webrick_to_use_ssl.html"&gt;here&lt;/a&gt;.  &lt;br /&gt;
&lt;br /&gt;
&lt;a href="https://telesales-rails.heroku.com/" style="font-size: 14pt; font-weight: strong;" target="_blank"&gt;You can run the app for yourself here.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
All of the &lt;a href="https://github.com/jeffdonthemic/Telesales-Rails"&gt;code for this app is hosted at github&lt;/a&gt; so feel free to fork it. I've pulled out some of the more important parts of the app for discussion after the video.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;object class="BLOGGER-youtube-video" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" data-thumbnail-src="http://0.gvt0.com/vi/fRAaodh9jxQ/0.jpg" height="343" width="560"&gt;&lt;param name="movie" value="http://www.youtube.com/v/fRAaodh9jxQ&amp;fs=1&amp;source=uds" /&gt;&lt;param name="bgcolor" value="#FFFFFF" /&gt;&lt;embed width="560" height="343" src="http://www.youtube.com/v/fRAaodh9jxQ&amp;fs=1&amp;source=uds" type="application/x-shockwave-flash"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/div&gt;&lt;br /&gt;
&lt;strong&gt;app/controllers/accounts_controller.rb&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
The account controller delegates authority to accounts.rb for integration with Force.com and then packages up the returns for the views.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush:java"&gt;require 'accounts'

class AccountsController &amp;lt; ApplicationController
  def index
  end
  
  def search
    @json = Accounts.search(params[:accountName])
  end
  
  def show
    @account = Accounts.retrieve(params[:id])
    @opportunities = Accounts.opportunities(params[:id])    
  end
  
  def create
     @account = Accounts.create
  end
  
  def edit
     @account = Accounts.retrieve(params[:id])
  end
  
  def save
    Accounts.save(params)
    redirect_to :action =&amp;gt; :show, :id =&amp;gt; params[:id]
  end  
  
  def new_opp 
    @account = Accounts.retrieve(params[:id])
  end
  
  def save_opp
    Accounts.create_opp(params)
    redirect_to :action =&amp;gt; :show, :id =&amp;gt; params[:id]
  end

end
&lt;/pre&gt;&lt;br /&gt;
&lt;strong&gt;lib/accounts.rb&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
Accounts.rb does most of the heavy lifting for the app. It prepares the requests to Force.com with the correct headers and makes the actual calls to Force.com with the REST API.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush:java"&gt;require 'rubygems'
require 'httparty'

class Accounts
  include HTTParty
  #doesn't seem to pick up env variable correctly if I set it here
  #headers 'Authorization' =&amp;gt; "OAuth #{ENV['sfdc_token']}"
  format :json
  # debug_output $stderr

  def self.set_headers
    headers 'Authorization' =&amp;gt; "OAuth #{ENV['sfdc_token']}"
  end

  def self.root_url
    @root_url = ENV['sfdc_instance_url']+"/services/data/v"+ENV['sfdc_api_version']
  end
  
  def self.search(keyword)
    Accounts.set_headers
    soql = "SELECT Id, Name, BillingCity, BillingState, Phone from Account Where Name = \'#{keyword}\'"
    get(Accounts.root_url+"/query/?q=#{CGI::escape(soql)}")
  end
  
  def self.create()
    Accounts.set_headers
    headers 'Content-Type' =&amp;gt; "application/json"
    
    options = {
      :body =&amp;gt; {
          :Name =&amp;gt; "1234"
      }.to_json
    }
    response = post(Accounts.root_url+"/sobjects/Account/", options)
    # puts response.body, response.code, response.message
  end
  
  def self.save(params)
    Accounts.set_headers
    headers 'Content-Type' =&amp;gt; "application/json"
    
    options = {
      :body =&amp;gt; {
          :billingcity =&amp;gt; params[:BillingCity]
      }.to_json
    }
    p options
    response = post(Accounts.root_url+"/sobjects/Account/#{params[:id]}?_HttpMethod=PATCH", options)
    # 201 response.body equals success
    # puts response.body, response.code, response.message
  end
  
  def self.retrieve(id)
    Accounts.set_headers
    get(Accounts.root_url+"/sobjects/Account/#{id}?fields=Id,Name,BillingCity,BillingState,Phone,Website") 
  end
  
  def self.opportunities(accountId)
    Accounts.set_headers
    soql = "SELECT Id, Name, Amount, StageName, Probability, CloseDate from Opportunity where AccountId = \'#{accountId}\'"
    get(Accounts.root_url+"/query/?q=#{CGI::escape(soql)}")
  end
  
  def self.create_opp(params)
    Accounts.set_headers
    headers 'Content-Type' =&amp;gt; "application/json"
    
    options = {
      :body =&amp;gt; {
          :name =&amp;gt; params[:name],
          :amount =&amp;gt; params[:amount],
          :accountId =&amp;gt; params[:id],
          :amount =&amp;gt; params[:amount],
          :closeDate =&amp;gt; params[:closeDate],
          :stageName =&amp;gt; params[:stageName]
      }.to_json
    }
    response = post(Accounts.root_url+"/sobjects/Opportunity/", options)
    # 201 response.body equals success
    # puts response.body, response.code, response.message
  end
 
end
&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6747272934569803137-1825235569855116922?l=techblog.appirio.com' alt='' /&gt;&lt;/div&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=_KD3L1hRDB4:5hBbjuNVZ4g:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=_KD3L1hRDB4:5hBbjuNVZ4g:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?i=_KD3L1hRDB4:5hBbjuNVZ4g:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=_KD3L1hRDB4:5hBbjuNVZ4g:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?i=_KD3L1hRDB4:5hBbjuNVZ4g:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/appiriotechblog?a=_KD3L1hRDB4:5hBbjuNVZ4g:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/appiriotechblog?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/appiriotechblog/~4/_KD3L1hRDB4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://techblog.appirio.com/feeds/1825235569855116922/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://techblog.appirio.com/2011/06/demo-app-ruby-rails-forcecom-rest-api.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/6747272934569803137/posts/default/1825235569855116922?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/6747272934569803137/posts/default/1825235569855116922?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/appiriotechblog/~3/_KD3L1hRDB4/demo-app-ruby-rails-forcecom-rest-api.html" title="Demo App - Ruby, Rails &amp; Force.com REST API on Heroku" /><author><name>Jeff Douglas</name><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-yH6OXRZAHQc/AAAAAAAAAAI/AAAAAAAAAUs/YNIXfF_sEE4/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://techblog.appirio.com/2011/06/demo-app-ruby-rails-forcecom-rest-api.html</feedburner:origLink></entry></feed>

