Skip to content

Instantly share code, notes, and snippets.

@speedmax
Created March 25, 2010 12:53
Show Gist options
  • Save speedmax/343520 to your computer and use it in GitHub Desktop.
Save speedmax/343520 to your computer and use it in GitHub Desktop.
MongoMapper ActiveModel serialization compatible
module ActiveModel::Compatible
extend ActiveSupport::Concern
extend ActiveModel::Naming
include ActiveModel::Serializers::Xml
include ActiveModel::Serializers::JSON
def to_xml(options = {}, &block)
options[:except] ||= []
options[:except] << :_id
super options do |b|
b.id self.id
block.call(b) if block_given?
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment