fix error
This commit is contained in:
parent
52358bb533
commit
164357aedf
|
@ -41,4 +41,7 @@ class AskCategorySetting
|
|||
field :usage_rule
|
||||
field :category_id
|
||||
field :title_layout, type: Integer
|
||||
field :email_regex_enable, type: Boolean, default: false
|
||||
field :email_regex, type: String, default: '\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z'
|
||||
|
||||
end
|
||||
|
|
|
@ -19,6 +19,11 @@ class AskSetting
|
|||
self.save
|
||||
end
|
||||
end
|
||||
after_save do
|
||||
if self.email_regex_enable_changed? || self.email_regex_changed?
|
||||
AskCategorySetting.all.update_all(email_regex_enable: self.email_regex_enable,email_regex: self.email_regex)
|
||||
end
|
||||
end
|
||||
def custom_fields
|
||||
tmp = super
|
||||
tmp.select{|k,v| v['delete'] != true}
|
||||
|
|
|
@ -26,15 +26,20 @@ module Ask
|
|||
end
|
||||
begin
|
||||
require File.expand_path('../../../app/models/ask_setting', __FILE__)
|
||||
require File.expand_path('../../../app/models/ask_category_setting', __FILE__)
|
||||
require File.expand_path('../../../app/models/ask_setting_index', __FILE__)
|
||||
if defined?(AskSetting)
|
||||
if AskSetting.first.nil?
|
||||
AskSetting.create()
|
||||
ask_setting = AskSetting.first
|
||||
if ask_setting.nil?
|
||||
ask_setting = AskSetting.create()
|
||||
elsif AskSetting.count > 1
|
||||
AskSetting.all[1..-1].each do |ask_setting|
|
||||
ask_setting.destroy
|
||||
AskSetting.all[1..-1].each do |a|
|
||||
a.destroy
|
||||
end
|
||||
end
|
||||
if ask_setting.email_regex_enable
|
||||
AskCategorySetting.all.update_all(email_regex_enable: ask_setting.email_regex_enable,email_regex: ask_setting.email_regex)
|
||||
end
|
||||
end
|
||||
if defined?(AskSettingIndex)
|
||||
if AskSettingIndex.first.nil?
|
||||
|
|
Loading…
Reference in New Issue