Class: RbacRls::RolesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rbac_rls/roles_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /roles



24
25
26
27
28
29
30
31
32
# File 'app/controllers/rbac_rls/roles_controller.rb', line 24

def create
  @role = Role.new(role_params)

  if @role.save
    redirect_to @role, notice: "Role was successfully created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject

DELETE /roles/1



44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/rbac_rls/roles_controller.rb', line 44

def destroy
  notice_msg = "Role was successfully destroyed."

  @role.destroy
  if @role.errors.size > 0
    notice_msg = @role.errors&.messages&.first&.last&.last
  end
  redirect_to roles_url, notice: notice_msg

end

#editObject

GET /roles/1/edit



20
21
# File 'app/controllers/rbac_rls/roles_controller.rb', line 20

def edit
end

#indexObject

GET /roles



6
7
8
# File 'app/controllers/rbac_rls/roles_controller.rb', line 6

def index
  @roles = Role.all
end

#newObject

GET /roles/new



15
16
17
# File 'app/controllers/rbac_rls/roles_controller.rb', line 15

def new
  @role = RbacRls::Role.new
end

#showObject

GET /roles/1



11
12
# File 'app/controllers/rbac_rls/roles_controller.rb', line 11

def show
end

#updateObject

PATCH/PUT /roles/1



35
36
37
38
39
40
41
# File 'app/controllers/rbac_rls/roles_controller.rb', line 35

def update
  if @role.update(role_params)
    redirect_to @role, notice: "Role was successfully updated."
  else
    render :edit, status: :unprocessable_entity
  end
end