tab/app/controllers/requests_controller.rb

27 lines
523 B
Ruby
Raw Normal View History

2017-01-09 15:46:43 +01:00
class RequestsController < ApplicationController
2019-03-24 22:31:03 +01:00
load_and_authorize_resource :user, find_by: :name
2017-01-09 15:46:43 +01:00
before_action :load_request, only: [:confirm, :decline]
authorize_resource :request, only: [:confirm, :decline]
def index
2017-01-09 16:22:58 +01:00
@requests = @user.incoming_requests.group_by(&:status)
2017-01-09 15:46:43 +01:00
end
def confirm
@request.confirm!
2017-01-14 16:22:44 +01:00
redirect_to root_path
2017-01-09 15:46:43 +01:00
end
def decline
@request.decline!
2017-01-14 16:22:44 +01:00
redirect_to root_path
2017-01-09 15:46:43 +01:00
end
private
def load_request
@request = Request.find params[:request_id]
end
end