質問編集履歴
2
link_toの先をcomunitiesに変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -160,7 +160,7 @@
|
|
160
160
|
|
161
161
|
.Group
|
162
162
|
|
163
|
-
= link_to
|
163
|
+
= link_to communities_path(group.id),class:"group-link" do
|
164
164
|
|
165
165
|
.Group__name
|
166
166
|
|
@@ -170,4 +170,6 @@
|
|
170
170
|
|
171
171
|
メッセージはまだありません
|
172
172
|
|
173
|
+
|
174
|
+
|
173
175
|
```
|
1
community_contollorerとcommunityのviewの記述。
test
CHANGED
File without changes
|
test
CHANGED
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
-
controllerの編集やどうしたらIDが
|
53
|
+
controllerの編集やどうしたらIDが見つかるかなど調べたのですが解決できませんでした。
|
54
54
|
|
55
55
|
### 補足情報(FW/ツールのバージョンなど)
|
56
56
|
|
@@ -60,21 +60,19 @@
|
|
60
60
|
|
61
61
|
group-controllerの記述はこれです。アドバイスお願いします。
|
62
62
|
|
63
|
+
```
|
64
|
+
|
63
|
-
class
|
65
|
+
class CommunitiesController < ApplicationController
|
66
|
+
|
67
|
+
before_action :set_group
|
64
68
|
|
65
69
|
|
66
70
|
|
67
71
|
def index
|
68
72
|
|
69
|
-
e
|
73
|
+
@community = Community.new
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
def new
|
74
|
-
|
75
|
-
@group = Group.new
|
76
|
-
|
77
|
-
@group.u
|
75
|
+
@communities = @group.communities.includes(:user)
|
78
76
|
|
79
77
|
end
|
80
78
|
|
@@ -82,43 +80,27 @@
|
|
82
80
|
|
83
81
|
def create
|
84
82
|
|
85
|
-
|
83
|
+
@community = @group.communities.new(community_params)
|
86
84
|
|
87
|
-
if @
|
85
|
+
if @community.save
|
88
86
|
|
89
|
-
redirect_to root_path, notice: '
|
87
|
+
redirect_to group_communities_path(@group), notice: 'メッセージが送信されました'
|
90
88
|
|
91
89
|
else
|
92
90
|
|
91
|
+
@communities = @group.communities.includes(:user)
|
92
|
+
|
93
|
+
flash.now[:alert] = 'メッセージを入力してください。'
|
94
|
+
|
93
|
-
render :ne
|
95
|
+
render :index
|
94
96
|
|
95
97
|
end
|
96
98
|
|
97
99
|
end
|
98
100
|
|
99
|
-
|
100
|
-
|
101
101
|
def edit
|
102
102
|
|
103
|
-
@group = G
|
103
|
+
@group = Glog.find(params[:id])
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
def update
|
110
|
-
|
111
|
-
@group = Group.find(params[:id])
|
112
|
-
|
113
|
-
if @group.update(group_params)
|
114
|
-
|
115
|
-
redirect_to group_messages_path(@group), notice: 'グループを更新しました'
|
116
|
-
|
117
|
-
else
|
118
|
-
|
119
|
-
render :edit
|
120
|
-
|
121
|
-
end
|
122
104
|
|
123
105
|
end
|
124
106
|
|
@@ -126,10 +108,66 @@
|
|
126
108
|
|
127
109
|
private
|
128
110
|
|
129
|
-
def group_params
|
130
111
|
|
112
|
+
|
113
|
+
def community_params
|
114
|
+
|
131
|
-
params.require(:
|
115
|
+
params.require(:community).permit(:content, :image).merge(user_id: current_user.id)
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
def set_group
|
122
|
+
|
123
|
+
@group = Group.find(params[:group_id])
|
132
124
|
|
133
125
|
end
|
134
126
|
|
135
127
|
end
|
128
|
+
|
129
|
+
```
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
.SideBar
|
136
|
+
|
137
|
+
.LeftHeader
|
138
|
+
|
139
|
+
.LeftHeader__list
|
140
|
+
|
141
|
+
%h3.LeftHeader__userName
|
142
|
+
|
143
|
+
= current_user.name
|
144
|
+
|
145
|
+
%ul.LeftHeader__iconList
|
146
|
+
|
147
|
+
%li.LeftHeader__Icon
|
148
|
+
|
149
|
+
= link_to new_group_path do
|
150
|
+
|
151
|
+
= icon('fas', 'edit')
|
152
|
+
|
153
|
+
=link_to edit_user_path(current_user),class:"icon" do
|
154
|
+
|
155
|
+
=icon('fas','cog')
|
156
|
+
|
157
|
+
.GroupList
|
158
|
+
|
159
|
+
- current_user.groups.each do |group|
|
160
|
+
|
161
|
+
.Group
|
162
|
+
|
163
|
+
= link_to group_messages_path(group.id),class:"group-link" do
|
164
|
+
|
165
|
+
.Group__name
|
166
|
+
|
167
|
+
= group.name
|
168
|
+
|
169
|
+
.Group__message
|
170
|
+
|
171
|
+
メッセージはまだありません
|
172
|
+
|
173
|
+
```
|