Sha256: 5483ec9335364e12366cb4001c7b20a393085a9cd4aae0733ca3e488c401d002

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

class Admin::SettingsController < AdminController
  before_filter :find_setting, :only => [:edit,:update,:destroy]
  filter_access_to [:index,:new,:create,:edit,:update,:destroy]
	
  def index
    @settings = Radmin::Setting.all
  end

  def new
    @setting = Radmin::Setting.new
  end
  
  def create
    Radmin::Setting["#{params[:setting]['key']}"] = params[:setting]['value']
    flash[:notice] = Radmin::I18n.t(:setting_sucessfully_created, :default => "Setting sucessfully created.")
    redirect_to admin_settings_url
  rescue ActiveRecord::RecordInvalid
    render :action => :new
  end
  
  def update
    @setting.value = params[:setting]['value']
    @setting.save!
    flash[:notice] = Radmin::I18n.t(:setting_sucessfully_updated, :default => "Setting sucessfully updated.")
    redirect_to admin_settings_url
  rescue ActiveRecord::RecordInvalid
    render :action => :edit
  end
  
  def destroy
    @setting.destroy
    flash[:notice] = Radmin::I18n.t(:setting_sucessfully_deleted, :default => "Setting sucessfully deleted.")
    redirect_to admin_settings_url
  end

  protected
    def find_setting
      @setting = Radmin::Setting.find(params[:id])
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radmin-0.2.0 app/controllers/admin/settings_controller.rb