mongoid rc_6 & fix bugs
This commit is contained in:
1 parent
f347b150cf
commit
bda67684bd
11 files changed
+70
-24
No files matched your search
@@ -6,7 +6,7 @@ class AttributeAttrModel
|
||||
field :i18n_variable_id, :type => BSON::ObjectId, :index => true
|
||||
field :markup
|
||||
field :locale, :type => Boolean
|
||||
field :options, :type => Array
|
||||
field :list_options, :type => Array
|
||||
|
||||
embedded_in :user_attribute_model, :inverse_of => :attribute_attr_models
|
||||
validates_uniqueness_of :key
|
||||
@@ -32,14 +32,14 @@ class AttributeAttrModel
|
||||
end
|
||||
end
|
||||
|
||||
# Convert the string options into an array
|
||||
def select_options=(var)
|
||||
self.options = var.gsub(' ', '').split(',')
|
||||
# Convert the string list_options into an array
|
||||
def select_list_options=(var)
|
||||
self.list_options = var.gsub(' ', '').split(',')
|
||||
end
|
||||
|
||||
# Convert the array options into a string
|
||||
def select_options
|
||||
self.options.to_a.join(', ')
|
||||
# Convert the array list_options into a string
|
||||
def select_list_options
|
||||
self.list_options.to_a.join(', ')
|
||||
end
|
||||
|
||||
# Check if the attribute_attr is set to be destroyed
|
||||
|
||||
@@ -3,7 +3,7 @@ class I18nVariable
|
||||
include Mongoid::Document
|
||||
|
||||
field :key
|
||||
field :document_class
|
||||
field :parent_id, :index => true
|
||||
field :document_class, :type => String
|
||||
field :parent_id, :type => BSON::ObjectId, :index => true
|
||||
|
||||
end
|
||||
@@ -21,6 +21,11 @@ class Item
|
||||
|
||||
before_validation :setup_default_value
|
||||
|
||||
# Destroy the i18n_variable
|
||||
def destroy_i18n_variable
|
||||
self.i18n_variable.destroy rescue nil
|
||||
end
|
||||
|
||||
def self.find_by_name(item_name)
|
||||
Item.first(:conditions => { :name => item_name, :is_published => true })
|
||||
end
|
||||
@@ -32,6 +37,11 @@ class Item
|
||||
nodes.reverse
|
||||
end
|
||||
|
||||
# Destroy the i18n_variable
|
||||
def destroy_i18n_variable
|
||||
self.i18n_variable.destroy rescue nil
|
||||
end
|
||||
|
||||
# Update or create the i18n_variable record
|
||||
def i18n_variable=(attr)
|
||||
if self.i18n_variable_id
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ class User
|
||||
before_update :clean_active_attributes
|
||||
|
||||
# Update or create the user_attribute records
|
||||
def user_attributes=(attrs)
|
||||
attrs.each do |attributes|
|
||||
def user_attributes=(*attrs)
|
||||
attrs[0].each do |attributes|
|
||||
if attributes[:id].blank?
|
||||
user_attributes.build(attributes)
|
||||
else
|
||||
|
||||
@@ -10,8 +10,8 @@ class UserAttributeModel
|
||||
after_update :destroy_attrs
|
||||
|
||||
# Update or create the attribute_attr_model records
|
||||
def attribute_attr_models=(attrs)
|
||||
attrs.each do |attributes|
|
||||
def attribute_attr_models=(*attrs)
|
||||
attrs[0].each do |attributes|
|
||||
if attributes[:id].blank?
|
||||
attribute_attr_models.build(attributes)
|
||||
else
|
||||
@@ -52,6 +52,7 @@ class UserAttributeModel
|
||||
attribute_attr_models.each do |a|
|
||||
if a.should_destroy?
|
||||
a.destroy
|
||||
a.destroy_i18n_variable
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user