Sha256: c0ac88ecc1b36af63442cd93b13b2ce44c72dbee55b5cd46c28466f1bfa6be1e
Contents?: true
Size: 1.25 KB
Versions: 24
Compression:
Stored size: 1.25 KB
Contents
# frozen_string_literal: true class Admin::SeoController < Admin::BaseController before_action :set_setting before_action :set_section 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 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 private def settings_params @settings_params ||= params.require(:setting).permit! end VALID_SECTIONS = %w(general titles permalinks).freeze def set_section section = params[:section] @section = VALID_SECTIONS.include?(section) ? section : "general" end def set_setting @setting = this_blog end end
Version data entries
24 entries across 24 versions & 2 rubygems