質問編集履歴
5
投稿完了画面を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -408,6 +408,26 @@
|
|
408
408
|
|
409
409
|
|
410
410
|
|
411
|
+
app/views/contact/create.html.erb
|
412
|
+
|
413
|
+
```
|
414
|
+
|
415
|
+
<div class="contents">
|
416
|
+
|
417
|
+
<div class="success">
|
418
|
+
|
419
|
+
<h3>投稿が完了しました。</h3>
|
420
|
+
|
421
|
+
<a class="btn" href="/top">一覧へ戻る</a>
|
422
|
+
|
423
|
+
</div>
|
424
|
+
|
425
|
+
</div>
|
426
|
+
|
427
|
+
```
|
428
|
+
|
429
|
+
|
430
|
+
|
411
431
|
|
412
432
|
|
413
433
|
###試したこと
|
4
\$vi config/environments/development\.rb
test
CHANGED
File without changes
|
test
CHANGED
@@ -288,6 +288,124 @@
|
|
288
288
|
|
289
289
|
|
290
290
|
|
291
|
+
$ vi config/environments/development.rb
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
```
|
296
|
+
|
297
|
+
Rails.application.configure do
|
298
|
+
|
299
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
# In the development environment your application's code is reloaded on
|
304
|
+
|
305
|
+
# every request. This slows down response time but is perfect for development
|
306
|
+
|
307
|
+
# since you don't have to restart the web server when you make code changes.
|
308
|
+
|
309
|
+
config.cache_classes = false
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
# Do not eager load code on boot.
|
314
|
+
|
315
|
+
config.eager_load = false
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
# Show full error reports and disable caching.
|
320
|
+
|
321
|
+
config.consider_all_requests_local = true
|
322
|
+
|
323
|
+
config.action_controller.perform_caching = false
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
# Don't care if the mailer can't send.
|
328
|
+
|
329
|
+
# ActionMailer
|
330
|
+
|
331
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
332
|
+
|
333
|
+
config.web_console.whitelisted_ips = '0.0.0.0/0'
|
334
|
+
|
335
|
+
config.action_mailer.raise_delivery_errors = true
|
336
|
+
|
337
|
+
config.action_mailer.delivery_method = :letter_opener_web
|
338
|
+
|
339
|
+
config.action_mailer.smtp_settings = {
|
340
|
+
|
341
|
+
:enable_starttls_auto => true,
|
342
|
+
|
343
|
+
:address => "smtp.gmail.com",
|
344
|
+
|
345
|
+
:port => 587,
|
346
|
+
|
347
|
+
:domain => 'gmail.com',
|
348
|
+
|
349
|
+
:user_name => "", #自分のgmailアドレス
|
350
|
+
|
351
|
+
:password => "", #自分のgmailアドレスのパスワード
|
352
|
+
|
353
|
+
:authentication => 'plain'
|
354
|
+
|
355
|
+
}
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
# Print deprecation notices to the Rails logger.
|
360
|
+
|
361
|
+
config.active_support.deprecation = :log
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
# Raise an error on page load if there are pending migrations.
|
366
|
+
|
367
|
+
config.active_record.migration_error = :page_load
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
372
|
+
|
373
|
+
# This option may cause significant delays in view rendering with a large
|
374
|
+
|
375
|
+
# number of complex assets.
|
376
|
+
|
377
|
+
config.assets.debug = true
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
382
|
+
|
383
|
+
# yet still be able to expire them through the digest params.
|
384
|
+
|
385
|
+
config.assets.digest = true
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
# Adds additional error checking when serving assets at runtime.
|
390
|
+
|
391
|
+
# Checks for improperly declared sprockets dependencies.
|
392
|
+
|
393
|
+
# Raises helpful error messages.
|
394
|
+
|
395
|
+
config.assets.raise_runtime_errors = true
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
# Raises error for missing translations
|
400
|
+
|
401
|
+
# config.action_view.raise_on_missing_translations = true
|
402
|
+
|
403
|
+
end
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
```
|
408
|
+
|
291
409
|
|
292
410
|
|
293
411
|
|
3
エラーメッセージの編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -88,14 +88,16 @@
|
|
88
88
|
|
89
89
|
|
90
90
|
|
91
|
-
validates :name, :
|
91
|
+
validates :name, :length => { minimum: 3, :too_short => 'お名前(ニックネームも可)を入力してください。'}
|
92
|
-
|
92
|
+
|
93
|
-
validates :email, :
|
93
|
+
validates :email, :length => { minimum: 3, :too_short => 'メールアドレスを入力してください。'}
|
94
|
-
|
94
|
+
|
95
|
-
validates :text, :presence => {:message => '
|
95
|
+
validates :text, :presence => {:message => 'メッセージを入力してください。'}
|
96
96
|
|
97
97
|
end
|
98
98
|
|
99
|
+
|
100
|
+
|
99
101
|
```
|
100
102
|
|
101
103
|
|
2
contact_controller\.rb
test
CHANGED
File without changes
|
test
CHANGED
@@ -176,18 +176,38 @@
|
|
176
176
|
|
177
177
|
@contact = Contact.new
|
178
178
|
|
179
|
+
render :action => 'index'
|
180
|
+
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
def create
|
186
|
+
|
187
|
+
@contact = Contact.new(contact_params)
|
188
|
+
|
179
189
|
end
|
180
190
|
|
181
191
|
|
182
192
|
|
183
193
|
def sendmail
|
184
194
|
|
185
|
-
arg = ContactModel.find(1)
|
186
|
-
|
187
|
-
@mail = ContactMailer.received_email(a
|
195
|
+
@mail = ContactMailer.received_email(@contact).deliver
|
188
196
|
|
189
197
|
render text: 'メール送信完了'
|
190
198
|
|
199
|
+
render :action => 'create'
|
200
|
+
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
private
|
206
|
+
|
207
|
+
def contact_params
|
208
|
+
|
209
|
+
params.require(:contact).permit(:name, :email, :text)
|
210
|
+
|
191
211
|
end
|
192
212
|
|
193
213
|
|
1
text\.rbの編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,20 +52,10 @@
|
|
52
52
|
|
53
53
|
```
|
54
54
|
|
55
|
+
webサイトから問い合わせがありました。
|
56
|
+
|
55
57
|
--------------------------
|
56
58
|
|
57
|
-
ご連絡、誠にありがとうございます。<br>
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
メッセージの内容を確認し、<br>
|
62
|
-
|
63
|
-
担当者より、折り返しご連絡させていただきます。<br>
|
64
|
-
|
65
|
-
しばらくお待ちください。
|
66
|
-
|
67
|
-
|
68
|
-
|
69
59
|
Name:<br>
|
70
60
|
|
71
61
|
<%= @contact.name %>
|