-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathfollow_requests_controller.rb
More file actions
71 lines (61 loc) · 2.23 KB
/
follow_requests_controller.rb
File metadata and controls
71 lines (61 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class FollowRequestsController < ApplicationController
before_action :set_follow_request, only: %i[ show edit update destroy ]
# GET /follow_requests or /follow_requests.json
def index
@follow_requests = FollowRequest.all
end
# GET /follow_requests/1 or /follow_requests/1.json
def show
end
# GET /follow_requests/new
def new
@follow_request = FollowRequest.new
end
# GET /follow_requests/1/edit
def edit
end
# POST /follow_requests or /follow_requests.json
def create
@follow_request = FollowRequest.new(follow_request_params)
@follow_request.sender = current_user
respond_to do |format|
if @follow_request.save
format.html { redirect_back fallback_location: root_url, notice: "Follow request was successfully created." }
format.json { render :show, status: :created, location: @follow_request }
format.js
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @follow_request.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /follow_requests/1 or /follow_requests/1.json
def update
respond_to do |format|
if @follow_request.update(follow_request_params)
format.html { redirect_back fallback_location: root_url, notice: "Follow request was successfully updated." }
format.json { render :show, status: :ok, location: @follow_request }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @follow_request.errors, status: :unprocessable_entity }
end
end
end
# DELETE /follow_requests/1 or /follow_requests/1.json
def destroy
@follow_request.destroy
respond_to do |format|
format.html { redirect_back fallback_location: root_url, notice: "Follow request was successfully destroyed." }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_follow_request
@follow_request = FollowRequest.find(params[:id])
end
# Only allow a list of trusted parameters through.
def follow_request_params
params.require(:follow_request).permit(:recipient_id, :sender_id, :status)
end
end