Reputation: 12605
I have a form which I'd like to save through a standard RESTful rails pattern, but I also need to insert a lead into SalesForce via post. Admittedly I'm quite a newbie on this - any suggestions on the most elegant way to do this?
Cheers...
Upvotes: 1
Views: 784
Reputation: 1807
You can do something like the following after your model save is successful.
res = Net::HTTP.post_form(URI.parse(SALESFORCE_URL),
{'param_name1' => param_value1})
result = res.body
Or use a salesforce gem to do that update. Something like http://rubygems.org/gems/activesalesforce
Upvotes: 1
Reputation: 40333
You receive the form and then, inside your controller, you make a call to Salesforce, possibly using something like RestClient
def create
@your_object = MyObject.new(params[:my_object])
@your_object.save
SalesforceService.post( @your_object )
redirect_to home_path
end
You could also use Resque to make this call in a background worker to make your requests faster.
Upvotes: 2