Story#107192666 - validation for settings that DS data allowed and Allow key data cannot be both true

This commit is contained in:
Vladimir Krylov 2015-11-16 12:52:26 +02:00 committed by Matt Farnsworth
parent e01599fb1a
commit e31087bf60
3 changed files with 26 additions and 6 deletions

View file

@ -7,12 +7,18 @@ class Admin::SettingsController < AdminController
end
def create
casted_settings.each do |k, v|
Setting[k] = v
end
@errors = Setting.params_errors(casted_settings)
if @errors.empty?
casted_settings.each do |k, v|
Setting[k] = v
end
flash[:notice] = I18n.t('records_updated')
redirect_to [:admin, :settings]
flash[:notice] = I18n.t('records_updated')
redirect_to [:admin, :settings]
else
flash[:alert] = @errors.values.uniq.join(", ")
render "admin/settings/index"
end
end
def show; end