mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-24 08:52:14 -04:00
DRY the roles controller
This commit is contained in:
@@ -1,67 +1,39 @@
|
||||
class RolesController < ApplicationController
|
||||
before_action :authenticate_member!
|
||||
load_and_authorize_resource
|
||||
respond_to :html
|
||||
|
||||
# GET /roles
|
||||
def index
|
||||
@roles = Role.all
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
end
|
||||
respond_with @roles
|
||||
end
|
||||
|
||||
# GET /roles/1
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
end
|
||||
respond_with @role
|
||||
end
|
||||
|
||||
# GET /roles/new
|
||||
def new
|
||||
@role = Role.new
|
||||
|
||||
respond_to do |format|
|
||||
format.html # new.html.erb
|
||||
end
|
||||
respond_with @role
|
||||
end
|
||||
|
||||
# GET /roles/1/edit
|
||||
def edit
|
||||
respond_with @role
|
||||
end
|
||||
|
||||
# POST /roles
|
||||
def create
|
||||
@role = Role.new(role_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @role.save
|
||||
format.html { redirect_to @role, notice: 'Role was successfully created.' }
|
||||
else
|
||||
format.html { render action: "new" }
|
||||
end
|
||||
end
|
||||
@role = Role.create(role_params)
|
||||
respond_with @role
|
||||
end
|
||||
|
||||
# PUT /roles/1
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @role.update(role_params)
|
||||
format.html { redirect_to @role, notice: 'Role was successfully updated.' }
|
||||
else
|
||||
format.html { render action: "edit" }
|
||||
end
|
||||
end
|
||||
@role.update(role_params)
|
||||
respond_with @role
|
||||
end
|
||||
|
||||
# DELETE /roles/1
|
||||
def destroy
|
||||
@role.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to roles_url }
|
||||
end
|
||||
respond_with @role
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user