Jason Vogel
2007-Jan-30 07:26 UTC
Dynamically control Model.Save to use ActiveRecord or ActionWebService
I have "requirement" to support a short term approach using
ActiveRecord.Save, but eventually migrate to a SOA environment.
Hence, I need to short-term with ActiveRecord and long-term with
ActionWebvService.
Right now, I''ve got a Controller that looks like
class OfferRenewalController < ApplicationController
def handle_payment
# Receive the ContractPayment "form fields" into an object
@contract_payment = ContractPayment.new(params[:contract_payment])
if (@contract_payment.valid?)
@contract_payment.save
else
# @contract_payment.errors.each_full { |msg| puts msg }
render :action => ''take_payment'', :id =>
@contract_payment
end
end # handle_payment
class ContractPayment < ActiveRecord::Base
end
And this works great for the short-term. How do I override the built-
in save method and conditonally use the "normal"ActiveRecord .save vs.
invoke some other WebService. I tried a dozen things and just
confused the hell out of myself. I would really appreciate a code
example with some explanation.
Thanks,
Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---