orbit-basic/app/models/user/user_attribute.rb

22 lines
480 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
2011-11-12 09:54:45 +00:00
def attribute_values=(*args)
2011-04-28 14:47:34 +00:00
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