質問編集履歴

1

chats_controller\.rbの内容修正

2016/06/09 11:29

投稿

straysheep
straysheep

スコア33

test CHANGED
File without changes
test CHANGED
@@ -64,7 +64,15 @@
64
64
 
65
65
 
66
66
 
67
+ chats_controller.rb
68
+
67
69
  ```
70
+
71
+ before_action :set_room
72
+
73
+ before_action :set_chat, except: [:create]
74
+
75
+
68
76
 
69
77
  def new
70
78
 
@@ -94,6 +102,40 @@
94
102
 
95
103
  end
96
104
 
105
+
106
+
107
+ private
108
+
109
+ def chat_params
110
+
111
+ params[:chat].permit(:comment)
112
+
113
+ end
114
+
115
+
116
+
117
+ def set_room
118
+
119
+ @room = Room.find(params[:room_id])
120
+
121
+ end
122
+
123
+
124
+
125
+ def set_chat
126
+
127
+ @chat = @room.chats.find(params[:id])
128
+
129
+ end
130
+
131
+
132
+
133
+ def room_params
134
+
135
+ @room = Room.find(params[:room_id])
136
+
137
+ end
138
+
97
139
  ```
98
140
 
99
141