質問編集履歴
2
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,92 @@
|
|
1
|
+
```ここに言語を入力
|
2
|
+
|
3
|
+
messages_controller.rb
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
def index
|
8
|
+
|
9
|
+
@message = Message.new
|
10
|
+
|
11
|
+
@messages = @group.messages.includes(:user)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
def edit
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
def create
|
24
|
+
|
25
|
+
@message = @group.messages.new(message_params)
|
26
|
+
|
27
|
+
if @message.save
|
28
|
+
|
29
|
+
redirect_to group_messages_path(@group), notice: 'メッセージが送信されました'
|
30
|
+
|
31
|
+
else
|
32
|
+
|
33
|
+
@messages = @group.messages.includes(:user)
|
34
|
+
|
35
|
+
flash.now[:alert] = 'メッセージを入力してください。'
|
36
|
+
|
37
|
+
render :index
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def message_params
|
48
|
+
|
49
|
+
params.require(:message).permit(:content, :image).merge(user_id: current_user.id)
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
def set_group
|
56
|
+
|
57
|
+
@group = Group.find(params[:group_id])
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
messagesのindex.html.haml
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
.form
|
70
|
+
|
71
|
+
= form_for [@group,@message] do |f|
|
72
|
+
|
73
|
+
= f.text_field :content, class: 'new__message', placeholder: 'type a message'
|
74
|
+
|
75
|
+
.form__mask
|
76
|
+
|
77
|
+
= f.label :image, class: 'image-label' do
|
78
|
+
|
79
|
+
= fa_icon 'picture-o', class: 'icon'
|
80
|
+
|
81
|
+
= f.file_field :image, class: 'hidden'
|
82
|
+
|
83
|
+
= f.submit 'Send', class: 'form__submit'
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
コード
|
88
|
+
|
1
|
-
NoMethodError in MessagesController#create
|
89
|
+
```NoMethodError in MessagesController#create
|
2
90
|
|
3
91
|
undefined method `text' for #<Message:0x00007fa3b9bc3e50> Did you mean? test
|
4
92
|
|
1
タイトル変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
エラー解決できません!
|
1
|
+
エラー解決できません!undefined method `text' for #<Message:0x00007fa3b9bc3e50> Did you mean? test
|
test
CHANGED
@@ -36,4 +36,4 @@
|
|
36
36
|
|
37
37
|
この部分でtestとでる意味がわからなくて・・・プログラミング初心者です、
|
38
38
|
|
39
|
-
ご教授お願いします。
|
39
|
+
ご教授お願いします。簡単なエラーだとは思うのですが解決できなくて。。。
|