質問編集履歴

2

ソースコード追加

2017/02/15 02:55

投稿

0xfee1900d
0xfee1900d

スコア10

test CHANGED
File without changes
test CHANGED
@@ -46,7 +46,7 @@
46
46
 
47
47
  Parameters: {"access_token"=>"ql05NTxxxxx"}
48
48
 
49
- Information Load (2.0ms) SELECT "micropost".* FROM "micropost" WHERE "micropost"."token" = ? LIMIT ? [["token", "ql05NTxxxxx"], ["LIMIT", 1]]
49
+ Micropost Load (2.0ms) SELECT "micropost".* FROM "micropost" WHERE "micropost"."token" = ? LIMIT ? [["token", "ql05NTxxxxx"], ["LIMIT", 1]]
50
50
 
51
51
  Rendering micropost/edit.html.erb within layouts/application
52
52
 
@@ -62,7 +62,7 @@
62
62
 
63
63
  Processing by MicropostController#update as HTML
64
64
 
65
- Parameters: {"utf8"=>"✓", "authenticity_token"=>"wb8ni196rHHcoJdMYxDSg1DA==", "information"=>{"title"=>"テスト", "content"=>"この投稿はテストです\r\n\r\n追加しました", "status"=>"published"}, "commit"=>"登録", "token"=>"2"
65
+ Parameters: {"utf8"=>"✓", "authenticity_token"=>"wb8ni196rHHcoJdMYxDSg1DA==", "micropost"=>{"title"=>"テスト", "content"=>"この投稿はテストです\r\n\r\n追加しました", "status"=>"published"}, "commit"=>"登録", "token"=>"2"
66
66
 
67
67
  ```
68
68
 
@@ -94,7 +94,7 @@
94
94
 
95
95
  # Never trust parameters from the scary internet, only allow the white list through.
96
96
 
97
- def information_params
97
+ def micropost_params
98
98
 
99
99
  params.require(:micropost).permit(:title, :content, :status)
100
100
 
@@ -104,6 +104,90 @@
104
104
 
105
105
 
106
106
 
107
+ new.html.erb, edit.html.erbは以下の通りになっております
108
+
109
+ ```
110
+
111
+ <section>
112
+
113
+ <h2>フォーム</h2>
114
+
115
+ <%= render 'form', micropost: @micropost %>
116
+
117
+ </section>
118
+
119
+ ```
120
+
121
+
122
+
123
+ _form.html.erb
124
+
125
+ ```
126
+
127
+ <%= form_for(micropost) do |f| %>
128
+
129
+ <% if micropost.errors.any? %>
130
+
131
+ <div id="error_explanation">
132
+
133
+ <h2><%= pluralize(micropost.errors.count, "error") %> prohibited this micropost from being saved:</h2>
134
+
135
+
136
+
137
+ <ul>
138
+
139
+ <% micropost.errors.full_messages.each do |message| %>
140
+
141
+ <li><%= message %></li>
142
+
143
+ <% end %>
144
+
145
+ </ul>
146
+
147
+ </div>
148
+
149
+ <% end %>
150
+
151
+
152
+
153
+ <dl>
154
+
155
+ <dt><span class="default-pink">必須</span><strong>タイトル</strong></dt>
156
+
157
+ <dd>
158
+
159
+ <%= f.text_field :title %>
160
+
161
+ </dd>
162
+
163
+ <dt><span class="default-pink">必須</span><strong>本文</strong></dt>
164
+
165
+ <dd>
166
+
167
+ <%= f.text_area :content %>
168
+
169
+ </dd>
170
+
171
+ <dt><span class="default-pink">必須</span><strong>公開状態</strong></dt>
172
+
173
+ <dd class="select">
174
+
175
+ <%= f.select :status, [ ["公開", "published"], ['非公開', "unpublish"], ["下書き", "draft"] ], :selected => "published" %>
176
+
177
+ </dd>
178
+
179
+ </dl>
180
+
181
+ <%= f.submit "登録", class: "default-pink" %>
182
+
183
+ <% end %>
184
+
185
+
186
+
187
+ ```
188
+
189
+
190
+
107
191
  この問題を解決したく思います.
108
192
 
109
193
  皆様のお知恵をお借りできればと思います.よろしくお願い致します.

1

エラー文の追記・Contollerのソースコード追記

2017/02/15 02:55

投稿

0xfee1900d
0xfee1900d

スコア10

test CHANGED
@@ -1 +1 @@
1
- rails5:scaffoldで生成したもののupdateした時のエラー
1
+ rails5:scaffoldでupdateした時のエラー
test CHANGED
@@ -34,6 +34,40 @@
34
34
 
35
35
 
36
36
 
37
+ pryで見たときはこのようになっております.
38
+
39
+ 編集画面へアクセス
40
+
41
+ ```
42
+
43
+ Started GET "/micropost/ql05NTxxxxx/edit" for 10.0.2.2 at 2017-02-15 02:36:34 +0000
44
+
45
+ Processing by MicropostController#edit as HTML
46
+
47
+ Parameters: {"access_token"=>"ql05NTxxxxx"}
48
+
49
+ Information Load (2.0ms) SELECT "micropost".* FROM "micropost" WHERE "micropost"."token" = ? LIMIT ? [["token", "ql05NTxxxxx"], ["LIMIT", 1]]
50
+
51
+ Rendering micropost/edit.html.erb within layouts/application
52
+
53
+ ```
54
+
55
+
56
+
57
+ submitした時
58
+
59
+ ```
60
+
61
+ Started PATCH "/micropost/2" for 10.0.2.2 at 2017-02-15 02:36:43 +0000
62
+
63
+ Processing by MicropostController#update as HTML
64
+
65
+ Parameters: {"utf8"=>"✓", "authenticity_token"=>"wb8ni196rHHcoJdMYxDSg1DA==", "information"=>{"title"=>"テスト", "content"=>"この投稿はテストです\r\n\r\n追加しました", "status"=>"published"}, "commit"=>"登録", "token"=>"2"
66
+
67
+ ```
68
+
69
+
70
+
37
71
  ###補足情報(言語/FW/ツール等のバージョンなど)
38
72
 
39
73
  Ruby 2.3.3
@@ -42,6 +76,34 @@
42
76
 
43
77
 
44
78
 
79
+ Controllerにて以下のように設定しております
80
+
81
+ ```
82
+
83
+ private
84
+
85
+ # Use callbacks to share common setup or constraints between actions.
86
+
87
+ def set_micropost
88
+
89
+ @micropost = Micropost.find_by( token: params[ :token ] )
90
+
91
+ end
92
+
93
+
94
+
95
+ # Never trust parameters from the scary internet, only allow the white list through.
96
+
97
+ def information_params
98
+
99
+ params.require(:micropost).permit(:title, :content, :status)
100
+
101
+ end
102
+
103
+ ```
104
+
105
+
106
+
45
107
  この問題を解決したく思います.
46
108
 
47
109
  皆様のお知恵をお借りできればと思います.よろしくお願い致します.