Sha256: fb2d392638878efad387eea4155789e1030d5883e0e8fa81d66d937fe81473d6

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

class Admin::SettingsController < Admin::ForestController
  before_action :set_setting, only: [:show, :edit, :update, :destroy]

  # GET /settings
  def index
    @settings = apply_scopes(Setting.all).by_title.page params[:page]
    authorize @settings
  end

  # GET /settings/1
  def show
    authorize @setting
  end

  # TODO: better pattern for disabling new actions
  # GET /settings/new
  # def new
  #   @setting = Setting.new
  #   authorize @setting
  # end

  # GET /settings/1/edit
  def edit
    authorize @setting
  end

  # POST /settings
  def create
    @setting = Setting.new(setting_params)
    authorize @setting

    if @setting.save
      redirect_to edit_admin_setting_path(@setting), notice: 'Setting was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /settings/1
  def update
    authorize @setting
    if @setting.update(setting_params)
      redirect_to edit_admin_setting_path(@setting), notice: 'Setting was successfully updated.'
    else
      render :edit
    end
  end

  # DELETE /settings/1
  # def destroy
  #   authorize @setting
  #   @setting.destroy
  #   redirect_to admin_settings_url, notice: 'Setting was successfully destroyed.'
  # end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_setting
      @setting = Setting.find(params[:id])
    end

    # Only allow a trusted parameter "white list" through.
    def setting_params
      params.require(:setting).permit(:value, :title, :slug, :value_type)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
forest_cms-0.98.1 app/controllers/admin/settings_controller.rb