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
480 B
Ruby

class UserAttribute
include Mongoid::Document
include Mongoid::Timestamps
field :key
has_many :attribute_values
# Update or create the attribute_value records
def attribute_values=(*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