tab/app/controllers/requests_controller.rb
2017-01-09 15:46:43 +01:00

26 lines
598 B
Ruby

class RequestsController < ApplicationController
load_and_authorize_resource :user, only: :index
before_action :load_request, only: [:confirm, :decline]
authorize_resource :request, only: [:confirm, :decline]
def index
@requests = User.find(params[:user_id]).incoming_requests.group_by(&:status)
end
def confirm
@request.confirm!
redirect_to user_requests_path(@request.debtor)
end
def decline
@request.decline!
redirect_to user_requests_path(@request.debtor)
end
private
def load_request
@request = Request.find params[:request_id]
end
end