Skip to content

Instantly share code, notes, and snippets.

@emachnic
Created March 25, 2011 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emachnic/887045 to your computer and use it in GitHub Desktop.
Save emachnic/887045 to your computer and use it in GitHub Desktop.
Trying to create a Mongoid document from params received through ActiveMerchant
class Donation
include Mongoid::Document
field :success, :type => String
field :authorization, :type => String
field :message, :type => String
field :params, :type => Hash, :default => {}
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
@paulelliott
Copy link

I tried it out locally and am seeing the same behavior you are. It looks like it might be a bug in Mongoid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment