/
statuses_controller.rb
85 lines (72 loc) · 1.99 KB
/
statuses_controller.rb
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
class StatusesController < ApplicationController
before_filter :authenticate_user!, only: [:new, :create, :edit, :update]
# GET /statuses
# GET /statuses.json
def index
@statuses = Status.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @statuses }
end
end
# GET /statuses/1
# GET /statuses/1.json
def show
@status = Status.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @status }
end
end
# GET /statuses/new
# GET /statuses/new.json
def new
@status = Status.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @status }
end
end
# GET /statuses/1/edit
def edit
@status = Status.find(params[:id])
end
# POST /statuses
# POST /statuses.json
def create
@status = Status.new(params[:status])
respond_to do |format|
if @status.save
format.html { redirect_to @status, notice: 'Status was successfully created.' }
format.json { render json: @status, status: :created, location: @status }
else
format.html { render action: "new" }
format.json { render json: @status.errors, status: :unprocessable_entity }
end
end
end
# PUT /statuses/1
# PUT /statuses/1.json
def update
@status = Status.find(params[:id])
respond_to do |format|
if @status.update_attributes(params[:status])
format.html { redirect_to @status, notice: 'Status was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @status.errors, status: :unprocessable_entity }
end
end
end
# DELETE /statuses/1
# DELETE /statuses/1.json
def destroy
@status = Status.find(params[:id])
@status.destroy
respond_to do |format|
format.html { redirect_to statuses_url }
format.json { head :no_content }
end
end
end