Rail 3+ activemerchant: Get data from association class

Hi

I’m using ActiveMerchant with Authorize.net and already setup 2 models
Order and Transaction. (http://railscasts.com/episodes/145-integrating-
active-merchant)

I would like to get error message from the transaction if error
occurred then output in flash message. Here is my code:

#models/order_transaction.rb

class OrderTransaction < ActiveRecord::Base
belongs_to :order
serialize :params

def response=(response)
self.success = response.success?
self.authorization = response.authorization
self.message = response.message
self.params = response.params
rescue ActiveMerchant::ActiveMerchantError => e
self.success = false
self.authorization = nil
self.message = e.message
self.params = {}
end
end

How do I get those data from OrderTransaction class such as message,
success… in order_controller?

Thank you!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs