質問編集履歴

1

更新

2019/01/08 17:31

投稿

dossy
dossy

スコア109

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,10 @@
1
1
  rails でsubやgsubメソッドを使おうとすると
2
2
 
3
+ ```
4
+
3
- ```undefined method `sub' for ["ruby"]:Array Did you mean? sum```
5
+ undefined method `sub' for ["ruby"]:Array Did you mean? sum
6
+
7
+ ```
4
8
 
5
9
  と怒られます。
6
10
 
@@ -10,7 +14,35 @@
10
14
 
11
15
  記述する場所がおかしいのでしょうか?(controllerに記述)
12
16
 
17
+ ```
13
18
 
19
+ create_content.sub(/ruby/, 'python') ##ここでエラー
20
+
21
+
22
+
23
+ private
24
+
25
+ def create_content ##valueのみを取得する処理
26
+
27
+ params.permit(:text).values
28
+
29
+ end
30
+
31
+ ```
32
+
33
+ ターミナル上では、
34
+
35
+ ```
36
+
37
+ create_content
38
+
39
+ Unpermitted parameters: :utf8, :authenticity_token
40
+
41
+ => ["ruby ruby ruby"]
42
+
43
+ valueのみを抽出はできているはずなのですが・・・
44
+
45
+ ```
14
46
 
15
47
  formで送られたtextのvalueだけを抽出し、別の言葉に変換する処理を書いているところです。
16
48