14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/comfy/admin/cms/seo_snippets_controller.rb', line 14
def create
@seo_snippet = SeoSnippet.new(params[:seo_snippet])
if seo_snippet_enhanced_params_are_valid?(params[:seo_snippet])
WriteSeoSnippet.write_snippet(params)
@snippet = @site.snippets.new(params.fetch(:snippet, {}).permit!)
@snippet.save!
flash[:success] = I18n.t('comfy.admin.cms.snippets.created')
redirect_to controller: 'snippets', action: 'edit', id: @snippet
else
array=[]
@seo_snippet.errors.messages.each do |error_key, error_message|
array << I18n.t('seo_snippet.'+error_key.to_s+'.'+error_message.join)
end
flash.now[:danger] = array.join(', ')
render :action => :new
end
rescue ActiveRecord::RecordInvalid
flash.now[:danger] = I18n.t('comfy.admin.cms.snippets.creation_failure')
render :action => :new
end
|