質問編集履歴

1

指摘いただいた内容を試してみました

2017/06/23 14:56

投稿

marutama_giant
marutama_giant

スコア16

test CHANGED
File without changes
test CHANGED
@@ -171,3 +171,101 @@
171
171
 
172
172
 
173
173
  現状、viewには従来のフォーム以外は表示されていません。
174
+
175
+
176
+
177
+
178
+
179
+ ##追記
180
+
181
+ ```ruby
182
+
183
+ <%= form_with(model: user, local: true) do |form| %>
184
+
185
+ <% if user.errors.any? %>
186
+
187
+ <div id="error_explanation">
188
+
189
+ <h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2>
190
+
191
+
192
+
193
+ <ul>
194
+
195
+ <% user.errors.full_messages.each do |message| %>
196
+
197
+ <li><%= message %></li>
198
+
199
+ <% end %>
200
+
201
+ </ul>
202
+
203
+ </div>
204
+
205
+ <% end %>
206
+
207
+
208
+
209
+ <div class="field">
210
+
211
+ <%= form.label :name %>
212
+
213
+ <%= form.text_field :name, id: :user_name %>
214
+
215
+ </div>
216
+
217
+
218
+
219
+ <div class="field">
220
+
221
+ <%= form.label :email %>
222
+
223
+ <%= form.text_field :email, id: :user_email %>
224
+
225
+ </div>
226
+
227
+
228
+
229
+ <div class="field">
230
+
231
+ <div id="star">こんにちは</div>
232
+
233
+ </div>
234
+
235
+
236
+
237
+ <script>
238
+
239
+ $('#star').raty({
240
+
241
+ size : 36,
242
+
243
+ starOff: '<%= asset_path('star-off.png') %>',
244
+
245
+ starOn : '<%= asset_path('star-on.png') %>',
246
+
247
+ scoreName: 'user[rate]'
248
+
249
+ });
250
+
251
+ </script>
252
+
253
+
254
+
255
+ <div class="actions">
256
+
257
+ <%= form.submit %>
258
+
259
+ </div>
260
+
261
+ <% end %>
262
+
263
+ ```
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+ ![イメージ説明](0bd2dde0e4805e693ab6d7dc4fc61f40.png)