-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.rb
78 lines (68 loc) · 1.84 KB
/
code.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
class AvatarsController < ApplicationController
before_action :set_avatar, only: [:show, :edit, :update, :destroy]
# GET /avatars
# GET /avatars.json
def index
if params[:secret] == ENV['ZOMG_SECRET']
@avatars = Avatar.order("created_at DESC")
else
head(418) and return#I'm a teapot!
end
end
# GET /avatars/1
# GET /avatars/1.json
def show
end
# GET /avatars/new
def new
@avatar = Avatar.new
end
# GET /avatars/1/edit
def edit
end
# POST /avatars
# POST /avatars.json
def create
@avatar = Avatar.new(avatar_params)
respond_to do |format|
if @avatar.save
format.html { head :created }
format.json { render :show, status: :created, location: @avatar }
else
format.html { render :new }
format.json { render json: @avatar.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /avatars/1
# PATCH/PUT /avatars/1.json
def update
respond_to do |format|
if @avatar.update(avatar_params)
format.html { redirect_to @avatar, notice: 'Avatar was successfully updated.' }
format.json { render :show, status: :ok, location: @avatar }
else
format.html { render :edit }
format.json { render json: @avatar.errors, status: :unprocessable_entity }
end
end
end
# DELETE /avatars/1
# DELETE /avatars/1.json
def destroy
@avatar.destroy
respond_to do |format|
format.html { redirect_to avatars_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_avatar
@avatar = Avatar.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def avatar_params
{repo: params[:repo], visage: params[:file]}
end
end