From 8a25ecc635de9893f372eac0d56c3703cc69633c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 28 May 2017 11:45:24 +1200 Subject: [PATCH] DRY the roles controller --- app/controllers/roles_controller.rb | 48 ++++++----------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 5c8b6f03d..05606c446 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -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