-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_words_controller.rb
83 lines (71 loc) · 1.92 KB
/
my_words_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
class MyWordsController < ApplicationController
# GET /my_words
# GET /my_words.json
def index
@my_words = MyWord.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @my_words }
end
end
# GET /my_words/1
# GET /my_words/1.json
def show
@my_word = MyWord.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @my_word }
end
end
# GET /my_words/new
# GET /my_words/new.json
def new
@my_word = MyWord.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @my_word }
end
end
# GET /my_words/1/edit
def edit
@my_word = MyWord.find(params[:id])
end
# POST /my_words
# POST /my_words.json
def create
@my_word = MyWord.new(params[:my_word])
respond_to do |format|
if @my_word.save
format.html { redirect_to @my_word, notice: 'My word was successfully created.' }
format.json { render json: @my_word, status: :created, location: @my_word }
else
format.html { render action: "new" }
format.json { render json: @my_word.errors, status: :unprocessable_entity }
end
end
end
# PUT /my_words/1
# PUT /my_words/1.json
def update
@my_word = MyWord.find(params[:id])
respond_to do |format|
if @my_word.update_attributes(params[:my_word])
format.html { redirect_to @my_word, notice: 'My word was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @my_word.errors, status: :unprocessable_entity }
end
end
end
# DELETE /my_words/1
# DELETE /my_words/1.json
def destroy
@my_word = MyWord.find(params[:id])
@my_word.destroy
respond_to do |format|
format.html { redirect_to my_words_url }
format.json { head :ok }
end
end
end