Sha256: bd8b72459c4ac9c1eb8f672bb564857daff6f6a75bb4d419a77b8a1db8fe3867

Contents?: true

Size: 1.47 KB

Versions: 14

Compression:

Stored size: 1.47 KB

Contents

class Admin::RolesController < Admin::ApplicationController

  before_action :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.includes(:spud_role_permissions)
    respond_with @roles
  end
  
  def show
    respond_with @role
  end
  
  def new
    @role = SpudRole.new
    respond_with @role
  end
  
  def create
    logger.debug 'role_params:'
    logger.debug role_params
    @role = SpudRole.new(role_params)
    flash[:notice] = 'SpudRole created successfully' if @role.save
    respond_with @role, :location => admin_roles_path
  end
  
  def edit
    respond_with @role
  end
  
  def update
    #role_params[:permission_tags] ||= []
    if @role.update_attributes(role_params)
      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

  def role_params
    params.require(:spud_role).permit(:name, :permission_tags => [])
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
tb_core-1.3.5 app/controllers/admin/roles_controller.rb
tb_core-1.3.4 app/controllers/admin/roles_controller.rb
tb_core-1.3.3 app/controllers/admin/roles_controller.rb
tb_core-1.3.2 app/controllers/admin/roles_controller.rb
tb_core-1.3.1 app/controllers/admin/roles_controller.rb
tb_core-1.3.0 app/controllers/admin/roles_controller.rb
tb_core-1.3.0.beta2 app/controllers/admin/roles_controller.rb
tb_core-1.3.0.beta1 app/controllers/admin/roles_controller.rb
tb_core-1.2.8 app/controllers/admin/roles_controller.rb
tb_core-1.2.7 app/controllers/admin/roles_controller.rb
tb_core-1.2.6 app/controllers/admin/roles_controller.rb
tb_core-1.2.4 app/controllers/admin/roles_controller.rb
tb_core-1.2.3 app/controllers/admin/roles_controller.rb
tb_core-1.2.2 app/controllers/admin/roles_controller.rb