Regexp is available in sensitive_words
This commit is contained in:
parent
303c14acad
commit
1a5f8964e1
2 changed files with 24 additions and 2 deletions
|
@ -11,6 +11,14 @@ module Admin
|
|||
def create
|
||||
authorize :sensitive_words, :create?
|
||||
|
||||
begin
|
||||
test_words
|
||||
rescue
|
||||
flash[:alert] = I18n.t('admin.ng_words.test_error')
|
||||
redirect_to after_update_redirect_path
|
||||
return
|
||||
end
|
||||
|
||||
@admin_settings = Form::AdminSettings.new(settings_params)
|
||||
|
||||
if @admin_settings.save
|
||||
|
@ -23,6 +31,12 @@ module Admin
|
|||
|
||||
private
|
||||
|
||||
def test_words
|
||||
sensitive_words = settings_params['sensitive_words'].split(/\r\n|\r|\n/)
|
||||
sensitive_words_for_full = settings_params['sensitive_words_for_full'].split(/\r\n|\r|\n/)
|
||||
Admin::NgWord.reject_with_custom_words?('Sample text', sensitive_words + sensitive_words_for_full)
|
||||
end
|
||||
|
||||
def after_update_redirect_path
|
||||
admin_sensitive_words_path
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue