質問編集履歴

2

コード追加

2017/08/29 13:56

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,53 @@
4
4
 
5
5
  メッセージの表示にflashを使用しているのですが、改行がうまくいきません。
6
6
 
7
+ ```ruby
7
8
 
9
+ def new
10
+
11
+ @test = Test.new
12
+
13
+ end
14
+
15
+
16
+
17
+ def create
18
+
19
+ @test = Test.create(test_params)
20
+
21
+ begin
22
+
23
+ @test.save!
24
+
25
+ redirect_to test_path
26
+
27
+ rescue => e
28
+
29
+ msg = { warning: e.message } # 「メッセージ1,メッセージ2,〜」のような形式の文字列
30
+
31
+ msg = msg.gsub(",","<br>")
32
+
33
+ flash[:alert] = msg
34
+
35
+ redirect_to new_test_path
36
+
37
+ end
38
+
39
+ end
40
+
41
+ ```
42
+
43
+
44
+
45
+ ```html
46
+
47
+ <h1>test</h1>
48
+
49
+ <p>メッセージ</p>
50
+
51
+ <%= flash[:alert].html_safe %>
52
+
53
+ ```
8
54
 
9
55
 
10
56
 

1

文章の修正

2017/08/29 13:56

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- flashの改行について
1
+ bootstrap flashの改行について
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ###前提・実現したいこと
2
2
 
3
- ruby on rails4にて開発をしています。
3
+ ruby on rails5にて開発をしています。
4
4
 
5
5
  メッセージの表示にflashを使用しているのですが、改行がうまくいきません。
6
6