ask/app/models/ask_setting.rb

20 lines
544 B
Ruby

class AskSetting
include Mongoid::Document
include Mongoid::Timestamps
after_initialize do
if default_setting.class != Hash
default_setting = {}
end
if custom_fields.class != Hash
custom_fields = {}
end
self.save
end
def custom_fields
tmp = super
tmp.select{|k,v| v['delete'] != true}
end
field :default_setting, type: Hash,default: {ask_category_id: true,name: true,sex: false,mail: true,phone: false,appointment: false,recaptcha: false}
field :custom_fields, type: Hash,default: {}
end