Sha256: 6255d41211a61c110916ba447a727d813d675458d4defc6e254f5f917c3b1d16

Contents?: true

Size: 1.03 KB

Versions: 24

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

class Admin::SettingsController < Admin::BaseController
  def index
    this_blog.base_url = blog_base_url if this_blog.base_url.blank?
    load_settings
  end

  def write
    load_settings
  end

  def feedback
    load_settings
  end

  def display
    load_settings
  end

  def update
    load_settings
    if @setting.update(settings_params)
      load_lang
      flash[:success] = I18n.t("admin.settings.update.success")
      redirect_to action: action_param
    else
      flash[:error] = I18n.t("admin.settings.update.error",
                             messages: this_blog.errors.full_messages.join(", "))
      render action_param
    end
  end

  private

  VALID_ACTIONS = %w(index write feedback display).freeze

  def settings_params
    @settings_params ||= params.require(:setting).permit!
  end

  def action_param
    @action_param ||=
      begin
        value = params[:from]
        VALID_ACTIONS.include?(value) ? value : "index"
      end
  end

  def load_settings
    @setting = this_blog
  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
publify_core-10.0.2 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.5.0 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.4.0 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.3.0 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.2.0 app/controllers/admin/settings_controller.rb
publify_core-10.0.1 app/controllers/admin/settings_controller.rb
publify_core-10.0.0 app/controllers/admin/settings_controller.rb
publify_core-9.2.10 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.1.1 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.1.0 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.0.3 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.0.2 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.0.1 app/controllers/admin/settings_controller.rb
HornsAndHooves-publify_core-10.0.0 app/controllers/admin/settings_controller.rb
publify_core-9.2.9 app/controllers/admin/settings_controller.rb
publify_core-9.2.8 app/controllers/admin/settings_controller.rb
publify_core-9.2.7 app/controllers/admin/settings_controller.rb
publify_core-9.2.6 app/controllers/admin/settings_controller.rb
publify_core-9.2.5 app/controllers/admin/settings_controller.rb
publify_core-9.2.4 app/controllers/admin/settings_controller.rb