This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
orbit-4-1/app/models/user/user_attribute.rb

22 lines
474 B
Ruby
Raw Normal View History

2011-04-28 14:47:34 +00:00
class UserAttribute
include Mongoid::Document
include Mongoid::Timestamps
field :key
has_many :attribute_values
# Update or create the attribute_value records
def attributes=(*args)
args[0].each do |value|
if value[:id].blank?
attribute_values.build(value)
else
attribute_value = attribute_values.detect {|a| a.id.to_s == value[:id].to_s }
attribute_value.update_attributes(value)
end
end
end
end