Sha256: b0098874a8b4a59653e575fef4e5abe6b32ed531b8ebfa7102f49a026496ede7

Contents?: true

Size: 1.31 KB

Versions: 10

Compression:

Stored size: 1.31 KB

Contents

class Admin::RolesController < Admin::ApplicationController

  before_filter :get_record, :only => [:show, :edit, :update, :destroy]
  respond_to :html, :json, :xml
  belongs_to_spud_app :users
  add_breadcrumb "Users", :admin_users_path
  add_breadcrumb "Roles", :admin_roles_path

  def index
    @roles = SpudRole.all
    respond_with @roles
  end
  
  def show
    respond_with @role
  end
  
  def new
    @role = SpudRole.new
    respond_with @role
  end
  
  def create
    @role = SpudRole.new(params[:spud_role])
    flash[:notice] = 'SpudRole created successfully' if @role.save
    respond_with @role, :location => admin_roles_path
  end
  
  def edit
    respond_with @role
  end
  
  def update
    params[:spud_role][:permission_tags] ||= []
    if @role.update_attributes(params[:spud_role])
      flash[:notice] = 'SpudRole updated successfully'
    end
    respond_with @role, :location => admin_roles_path
  end
  
  def destroy
    flash[:notice] = 'SpudRole deleted successfully' if @role.destroy
    respond_with @role, :location => admin_roles_path
  end

  private

  def get_record
    begin
      @role = SpudRole.find(params[:id])
    rescue ActiveRecord::RecordNotFound => e
      flash[:error] = "Could not find the requested SpudRole"
      redirect_to admin_roles_path
      return false
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tb_core-1.1.10 app/controllers/admin/roles_controller.rb
tb_core-1.1.9 app/controllers/admin/roles_controller.rb
tb_core-1.1.8 app/controllers/admin/roles_controller.rb
tb_core-1.1.7 app/controllers/admin/roles_controller.rb
tb_core-1.1.6 app/controllers/admin/roles_controller.rb
tb_core-1.1.5 app/controllers/admin/roles_controller.rb
tb_core-1.1.4 app/controllers/admin/roles_controller.rb
tb_core-1.1.2 app/controllers/admin/roles_controller.rb
tb_core-1.1.1 app/controllers/admin/roles_controller.rb
tb_core-1.1.0 app/controllers/admin/roles_controller.rb