Dynamically control Model.Save to use ActiveRecord or Action


#1

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