Class: Admin::SeoController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/seo_controller.rb

Instance Method Summary collapse

Methods included from BlogHelper

#blog_base_url, #this_blog

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
# File 'app/controllers/admin/seo_controller.rb', line 7

def show
  if @setting.permalink_format != "/%year%/%month%/%day%/%title%" &&
      @setting.permalink_format != "/%year%/%month%/%title%" &&
      @setting.permalink_format != "/%title%"
    @setting.custom_permalink = @setting.permalink_format
    @setting.permalink_format = "custom"
  end
end

#updateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/controllers/admin/seo_controller.rb', line 16

def update
  if settings_params[:permalink_format] == "custom"
    settings_params[:permalink_format] = settings_params[:custom_permalink]
  end
  if @setting.update(settings_params)
    flash[:success] = I18n.t("admin.settings.update.success")
    redirect_to admin_seo_path(section: @section)
  else
    flash[:error] = I18n.t("admin.settings.update.error",
                           messages: this_blog.errors.full_messages.join(", "))
    render :show
  end
end