質問編集履歴
2
viewファイルとroutesの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -33,3 +33,181 @@
|
|
33
33
|
end
|
34
34
|
|
35
35
|
```
|
36
|
+
|
37
|
+
**edit.html**
|
38
|
+
|
39
|
+
```
|
40
|
+
|
41
|
+
<% @page_title = "ブログ記事の編集" %>
|
42
|
+
|
43
|
+
<h1><%= @page_title %></h1>
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
<div class="toolbar"><%= link_to "記事の表示に戻る", @entry %></div>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
<%= form_for @entry do |form| %>
|
52
|
+
|
53
|
+
<%= render "form", form: form %>
|
54
|
+
|
55
|
+
<div><%= form.submit %></div>
|
56
|
+
|
57
|
+
<% end %>
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
edit.htmlのrender先の_form.html
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
<%= render "shared/errors", obj: @entry %>
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<table class="attr">
|
70
|
+
|
71
|
+
<tr>
|
72
|
+
|
73
|
+
<th width="80"><%= form.label :title %></th>
|
74
|
+
|
75
|
+
<td><%= form.text_field :title, size: 50 %></td>
|
76
|
+
|
77
|
+
</tr>
|
78
|
+
|
79
|
+
<tr>
|
80
|
+
|
81
|
+
<th><%= form.label :body %></th>
|
82
|
+
|
83
|
+
<td><%= form.text_area :body, rows: 10, cols: 45 %></td>
|
84
|
+
|
85
|
+
</tr>
|
86
|
+
|
87
|
+
<tr>
|
88
|
+
|
89
|
+
<th><%= form.label :posted_at, for: "entry_posted_at_1i" %></th>
|
90
|
+
|
91
|
+
<td><%= form.datetime_select :posted_at,
|
92
|
+
|
93
|
+
start_year: 2000, end_year: Time.current.year + 1,
|
94
|
+
|
95
|
+
use_month_numbers: true %></td>
|
96
|
+
|
97
|
+
</tr>
|
98
|
+
|
99
|
+
<tr>
|
100
|
+
|
101
|
+
<th><%= form.label :status %></th>
|
102
|
+
|
103
|
+
<td><%= form.select :status, Entry.status_options %></td>
|
104
|
+
|
105
|
+
</tr>
|
106
|
+
|
107
|
+
</table>
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
routes
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
```
|
118
|
+
|
119
|
+
Prefix Verb URI Pattern Controller#Action
|
120
|
+
|
121
|
+
entries_index GET /entries/index(.:format) entries#index
|
122
|
+
|
123
|
+
entries_show GET /entries/show(.:format) entries#show
|
124
|
+
|
125
|
+
entries_new GET /entries/new(.:format) entries#new
|
126
|
+
|
127
|
+
entries_edit GET /entries/edit(.:format) entries#edit
|
128
|
+
|
129
|
+
passwords_edit GET /passwords/edit(.:format) passwords#edit
|
130
|
+
|
131
|
+
accounts_show GET /accounts/show(.:format) accounts#show
|
132
|
+
|
133
|
+
accounts_edit GET /accounts/edit(.:format) accounts#edit
|
134
|
+
|
135
|
+
top_index GET /top/index(.:format) top#index
|
136
|
+
|
137
|
+
search_members GET /members/search(.:format) members#search
|
138
|
+
|
139
|
+
member_entries GET /members/:member_id/entries(.:format) entries#index
|
140
|
+
|
141
|
+
members GET /members(.:format) members#index
|
142
|
+
|
143
|
+
POST /members(.:format) members#create
|
144
|
+
|
145
|
+
new_member GET /members/new(.:format) members#new
|
146
|
+
|
147
|
+
edit_member GET /members/:id/edit(.:format) members#edit
|
148
|
+
|
149
|
+
member GET /members/:id(.:format) members#show
|
150
|
+
|
151
|
+
PATCH /members/:id(.:format) members#update
|
152
|
+
|
153
|
+
PUT /members/:id(.:format) members#update
|
154
|
+
|
155
|
+
DELETE /members/:id(.:format) members#destroy
|
156
|
+
|
157
|
+
root GET / top#index
|
158
|
+
|
159
|
+
about GET /about(.:format) top#about
|
160
|
+
|
161
|
+
session DELETE /session(.:format) sessions#destroy
|
162
|
+
|
163
|
+
POST /session(.:format) sessions#create
|
164
|
+
|
165
|
+
edit_account GET /account/edit(.:format) accounts#edit
|
166
|
+
|
167
|
+
account GET /account(.:format) accounts#show
|
168
|
+
|
169
|
+
PATCH /account(.:format) accounts#update
|
170
|
+
|
171
|
+
PUT /account(.:format) accounts#update
|
172
|
+
|
173
|
+
edit_password GET /password/edit(.:format) passwords#edit
|
174
|
+
|
175
|
+
password GET /password(.:format) passwords#show
|
176
|
+
|
177
|
+
PATCH /password(.:format) passwords#update
|
178
|
+
|
179
|
+
PUT /password(.:format) passwords#update
|
180
|
+
|
181
|
+
articles GET /articles(.:format) articles#index
|
182
|
+
|
183
|
+
POST /articles(.:format) articles#create
|
184
|
+
|
185
|
+
new_article GET /articles/new(.:format) articles#new
|
186
|
+
|
187
|
+
edit_article GET /articles/:id/edit(.:format) articles#edit
|
188
|
+
|
189
|
+
article GET /articles/:id(.:format) articles#show
|
190
|
+
|
191
|
+
PATCH /articles/:id(.:format) articles#update
|
192
|
+
|
193
|
+
PUT /articles/:id(.:format) articles#update
|
194
|
+
|
195
|
+
DELETE /articles/:id(.:format) articles#destroy
|
196
|
+
|
197
|
+
entries GET /entries(.:format) entries#index
|
198
|
+
|
199
|
+
POST /entries(.:format) entries#create
|
200
|
+
|
201
|
+
new_entry GET /entries/new(.:format) entries#new
|
202
|
+
|
203
|
+
edit_entry GET /entries/:id/edit(.:format) entries#edit
|
204
|
+
|
205
|
+
entry GET /entries/:id(.:format) entries#show
|
206
|
+
|
207
|
+
PATCH /entries/:id(.:format) entries#update
|
208
|
+
|
209
|
+
PUT /entries/:id(.:format) entries#update
|
210
|
+
|
211
|
+
DELETE /entries/:id(.:format) entries#destroy
|
212
|
+
|
213
|
+
```
|
1
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,11 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
+
下記のURLで編集画面があった場合、updateは以下のようにかけると思います(著書から抜粋している)。
|
8
|
+
|
9
|
+
|
10
|
+
|
7
|
-
|
11
|
+
このupdateアクションにある二つのparamsはどこからデータを受け取っているのですか?僕の予想だと1つめは下記のURLのentries/10/の10の部分、二つ目はentries/の部分でしょうか?複数と単数で異なる気がするのですが、どなたか説明していただけると幸いです。また二つ目のparamsの中身はidじゃいけないのでしょうか?
|
8
12
|
|
9
13
|
|
10
14
|
|