質問編集履歴
9
質問の修正と考察の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -215,5 +215,8 @@
|
|
215
215
|
None
|
216
216
|
```
|
217
217
|
!修正
|
218
|
+
devise :database_authenticatable, :registerable,
|
219
|
+
:recoverable, :rememberable, :trackable, :validatable
|
220
|
+
をuser.rbに追加したときに応募を押した際、deviseのサインインが作動し、ログインが2重になりました。
|
218
|
-
|
221
|
+
もしかすると、deviseがいらないのかなとも思い始めました。
|
219
|
-
|
222
|
+
|
8
質問の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -31,99 +31,64 @@
|
|
31
31
|
end
|
32
32
|
```
|
33
33
|
|
34
|
-
|
35
|
-
```
|
36
|
-
<
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
<% end %>
|
93
|
-
<% end %>
|
94
|
-
|
95
|
-
|
96
|
-
<%= link_to '応募する', '/' %>
|
97
|
-
<%= link_to '戻る', '/' %>
|
98
|
-
</div>
|
99
|
-
</div>
|
100
|
-
<% end %>
|
101
|
-
<% else %>
|
102
|
-
<div class='plan-content'>
|
103
|
-
<h4><%= @plan.title %></h4>
|
104
|
-
<h5><%= link_to @plan.user.name, user_path(@plan.user)%></h5>
|
105
|
-
<p><%= @plan.start_on %>~<%= @plan.end_on %></p>
|
106
|
-
<p><%= image_tag @plan.photo.url, :alt => '企画書イメージ図' if @plan.photo? %></p>
|
107
|
-
<p><%= @plan.detail %></p>
|
108
|
-
<div class= "address-content">
|
109
|
-
<h5>希望条件</h5>
|
110
|
-
<p><%= @plan.conditions %></p>
|
111
|
-
</div>
|
112
|
-
<div class= "number-content">
|
113
|
-
<h5>電話番号</h5>
|
114
|
-
<p><%= @plan.user.telephone_number %></p>
|
115
|
-
</div>
|
116
|
-
<div class= "address-content">
|
117
|
-
<h5>住所</h5>
|
118
|
-
<p><%= @plan.user.address %></p>
|
119
|
-
</div>
|
120
|
-
<div class="plan-content-btn">
|
121
|
-
<%= link_to '応募する', login_path %>
|
122
|
-
<%= link_to '戻る', '/' %>
|
123
|
-
</div>
|
124
|
-
</div>
|
125
|
-
|
126
|
-
<% end %>
|
34
|
+
! モデル/user.rb
|
35
|
+
```
|
36
|
+
class User < ApplicationRecord
|
37
|
+
# Include default devise modules. Others available are:
|
38
|
+
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
|
39
|
+
before_save { self.email.downcase! }
|
40
|
+
validates :name, presence: true, length: { maximum: 50 }
|
41
|
+
validates :email, presence: true, length: { maximum: 255 },
|
42
|
+
format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i },
|
43
|
+
uniqueness: { case_sensitive: false }
|
44
|
+
validates :furiganaName, presence: true, length: { maximum: 100 },
|
45
|
+
format: { with: /\A[ぁ-ん]+\z/u }
|
46
|
+
validates :telephone_number, numericality: { only_integer: true }, length: { maximum:11 },
|
47
|
+
format: { with: /\A[0-9]+\z/ }
|
48
|
+
validates :password, presence: true, length: { minimum: 6 }
|
49
|
+
validates :self_introduction, presence: false, length: { maximum: 1000 }
|
50
|
+
mount_uploader :image, ImageUploader
|
51
|
+
|
52
|
+
has_secure_password
|
53
|
+
has_many :plans
|
54
|
+
has_many :relationships
|
55
|
+
has_many :followings, through: :relationships, source: :follow
|
56
|
+
has_many :reverses_of_relationship, class_name: 'Relationship', foreign_key: 'follow_id'
|
57
|
+
has_many :followers, through: :reverses_of_relationship, source: :user
|
58
|
+
has_many :favorites, dependent: :destroy
|
59
|
+
has_many :favorite_plans, through: :favorites, source: :plan
|
60
|
+
has_many :entries, dependent: :destroy
|
61
|
+
has_many :messages, dependent: :destroy
|
62
|
+
|
63
|
+
def follow(other_user)
|
64
|
+
unless self == other_user
|
65
|
+
self.relationships.find_or_create_by(follow_id: other_user.id)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def unfollow(other_user)
|
70
|
+
relationship = self.relationships.find_by(follow_id: other_user.id)
|
71
|
+
relationship.destroy if relationship
|
72
|
+
end
|
73
|
+
|
74
|
+
def following?(other_user)
|
75
|
+
self.followings.include?(other_user)
|
76
|
+
end
|
77
|
+
|
78
|
+
def favorite(plan)
|
79
|
+
self.favorites.find_or_create_by(plan_id: plan.id)
|
80
|
+
end
|
81
|
+
|
82
|
+
def unfavorite(plan)
|
83
|
+
favorite = self.favorites.find_by(plan_id: plan.id)
|
84
|
+
favorite.destroy if favorite
|
85
|
+
end
|
86
|
+
|
87
|
+
def is_favorite?(plan)
|
88
|
+
self.favorite_plans.include?(plan)
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
127
92
|
```
|
128
93
|
!一通りメッセージ機能が形成できましたら、応募済みの方は再度応募ボタンを押せないようにしたいと考えております。
|
129
94
|
|
7
質問に対しての追加の状況説明
test
CHANGED
File without changes
|
test
CHANGED
@@ -249,4 +249,6 @@
|
|
249
249
|
|
250
250
|
None
|
251
251
|
```
|
252
|
-
|
252
|
+
!修正
|
253
|
+
roomは作成はされているようです。
|
254
|
+
|
6
エラーの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -127,91 +127,7 @@
|
|
127
127
|
```
|
128
128
|
!一通りメッセージ機能が形成できましたら、応募済みの方は再度応募ボタンを押せないようにしたいと考えております。
|
129
129
|
|
130
|
-
|
130
|
+
|
131
|
-
```
|
132
|
-
class PlansController < ApplicationController
|
133
|
-
before_action :set_plan, only: [:show, :edit, :update, :destroy ]
|
134
|
-
before_action :require_user_logged_in
|
135
|
-
before_action :current_user, only: [:destroy, :edit, :new]
|
136
|
-
before_action :require_user_logged_in, only: [:edit]
|
137
|
-
before_action :plan_destroy, only: [:show, :index]
|
138
|
-
|
139
|
-
def index
|
140
|
-
@pagy, @plans = pagy(Plan.order(id: :desc))
|
141
|
-
end
|
142
|
-
|
143
|
-
def show
|
144
|
-
|
145
|
-
#メッセージ機能の記述
|
146
|
-
@current_entry = Entry.where(user_id: current_user.id)
|
147
|
-
@another_entry = Entry.where(user_id: @plan.user.id)
|
148
|
-
unless @plan.user.id == current_user.id
|
149
|
-
@current_entry.each do |current|
|
150
|
-
@another_entry.each do |another|
|
151
|
-
if current.room_id == another.room_id
|
152
|
-
@is_room = true
|
153
|
-
@room_id = current.room_id
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
157
|
-
unless @is_room
|
158
|
-
@room = Room.new
|
159
|
-
@entry = Entry.new
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
164
|
-
|
165
|
-
def new
|
166
|
-
@plan = Plan.new
|
167
|
-
if @plan.user == current_user
|
168
|
-
redirect_to '/'
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
def create
|
173
|
-
@plan = current_user.plans.build(plan_params)
|
174
|
-
|
175
|
-
if @plan.save
|
176
|
-
flash[:success] = '企画掲載を設定しました'
|
177
|
-
redirect_to root_url
|
178
|
-
else
|
179
|
-
@pagy, @plans = pagy(current_user.plans.order(id: :desc))
|
180
|
-
flash.now[:danger] = '企画掲載に失敗しました'
|
181
|
-
render 'plans/new'
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
def destroy
|
186
|
-
@plan = Plan.find_by(id: params[:id])
|
187
|
-
@plan.destroy
|
188
|
-
flash[:success] = '掲載を中止しました。'
|
189
|
-
redirect_to("/")
|
190
|
-
end
|
191
|
-
|
192
|
-
|
193
|
-
private
|
194
|
-
def set_plan
|
195
|
-
@plan = Plan.find(params[:id])
|
196
|
-
end
|
197
|
-
|
198
|
-
def plan_params
|
199
|
-
params.require(:plan).permit(:title, :photo, :detail, :start_on, :end_on, :conditions)
|
200
|
-
end
|
201
|
-
|
202
|
-
def plan_destroy
|
203
|
-
Plan.where('end_on < ?', Date.today).destroy_all
|
204
|
-
end
|
205
|
-
|
206
|
-
def correct_user
|
207
|
-
@plan = current_user.plans.find_by(id: params[:id])
|
208
|
-
unless @plan
|
209
|
-
redirect_to root_url
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
end
|
214
|
-
```
|
215
131
|
|
216
132
|
私自身で考えてみたのは、rooms.controllerの
|
217
133
|
```
|
@@ -241,39 +157,91 @@
|
|
241
157
|
end
|
242
158
|
```
|
243
159
|
|
244
|
-
|
160
|
+
|
245
|
-
色々と試していたところ、plan/showページの時点で下記のエラーが発生しました。
|
246
|
-
最初の質問時点ではshowは正常に作動し、応募ボタンを押すまではできていたのですが
|
247
|
-
plans_controllerのコードを載せたいと思います。
|
248
|
-
|
249
|
-
```
|
161
|
+
```
|
250
|
-
|
162
|
+
NoMethodError in RoomsController#show
|
251
|
-
Showing /home/ubuntu/environment/tsunageru/app/views/plans/show.html.erb where line #52 raised:
|
252
|
-
|
253
|
-
|
163
|
+
undefined method `authentication_keys' for User:Class
|
254
|
-
Extracted source (around line #
|
164
|
+
Extracted source (around line #22):
|
255
|
-
|
165
|
+
20
|
256
|
-
|
166
|
+
21
|
257
|
-
|
167
|
+
22
|
258
|
-
|
168
|
+
23
|
259
|
-
|
169
|
+
24
|
260
|
-
5
|
170
|
+
25
|
261
171
|
|
262
|
-
<p class="user-show-room"><a href="/rooms/<%= @roomId %>" class="btn btn-primary btn-lg">メッセージへ</a>
|
263
|
-
<% else %>
|
264
|
-
<%= form_for @room do |f| %>
|
265
|
-
|
172
|
+
send(name, *arguments, &block)
|
173
|
+
else
|
266
|
-
|
174
|
+
super
|
267
|
-
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
268
178
|
|
269
179
|
Rails.root: /home/ubuntu/environment/tsunageru
|
270
180
|
|
271
181
|
Application Trace | Framework Trace | Full Trace
|
182
|
+
activerecord (6.1.6) lib/active_record/dynamic_matchers.rb:22:in `method_missing'
|
183
|
+
devise (4.8.1) lib/devise/failure_app.rb:104:in `i18n_message'
|
184
|
+
devise (4.8.1) lib/devise/failure_app.rb:84:in `redirect'
|
185
|
+
devise (4.8.1) lib/devise/failure_app.rb:43:in `respond'
|
186
|
+
actionpack (6.1.6) lib/abstract_controller/base.rb:228:in `process_action'
|
187
|
+
actionpack (6.1.6) lib/abstract_controller/base.rb:165:in `process'
|
188
|
+
actionpack (6.1.6) lib/action_controller/metal.rb:190:in `dispatch'
|
189
|
+
actionpack (6.1.6) lib/action_controller/metal.rb:238:in `block in action'
|
190
|
+
devise (4.8.1) lib/devise/failure_app.rb:23:in `call'
|
191
|
+
devise (4.8.1) lib/devise/delegator.rb:7:in `call'
|
192
|
+
warden (1.2.9) lib/warden/manager.rb:143:in `call_failure_app'
|
193
|
+
warden (1.2.9) lib/warden/manager.rb:129:in `process_unauthenticated'
|
194
|
+
warden (1.2.9) lib/warden/manager.rb:44:in `call'
|
195
|
+
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
|
272
|
-
a
|
196
|
+
rack (2.2.3) lib/rack/etag.rb:27:in `call'
|
197
|
+
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
|
198
|
+
rack (2.2.3) lib/rack/head.rb:12:in `call'
|
199
|
+
actionpack (6.1.6) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
|
200
|
+
actionpack (6.1.6) lib/action_dispatch/http/content_security_policy.rb:19:in `call'
|
201
|
+
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
|
202
|
+
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
|
203
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/cookies.rb:689:in `call'
|
204
|
+
activerecord (6.1.6) lib/active_record/migration.rb:601:in `call'
|
205
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
|
206
|
+
activesupport (6.1.6) lib/active_support/callbacks.rb:98:in `run_callbacks'
|
207
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
|
208
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
|
209
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
|
210
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
|
211
|
+
web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app'
|
212
|
+
web-console (4.2.0) lib/web_console/middleware.rb:19:in `block in call'
|
213
|
+
web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch'
|
214
|
+
web-console (4.2.0) lib/web_console/middleware.rb:17:in `call'
|
215
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
|
216
|
+
railties (6.1.6) lib/rails/rack/logger.rb:37:in `call_app'
|
217
|
+
railties (6.1.6) lib/rails/rack/logger.rb:26:in `block in call'
|
218
|
+
activesupport (6.1.6) lib/active_support/tagged_logging.rb:99:in `block in tagged'
|
219
|
+
activesupport (6.1.6) lib/active_support/tagged_logging.rb:37:in `tagged'
|
220
|
+
activesupport (6.1.6) lib/active_support/tagged_logging.rb:99:in `tagged'
|
221
|
+
railties (6.1.6) lib/rails/rack/logger.rb:26:in `call'
|
222
|
+
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
|
223
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
|
224
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/request_id.rb:26:in `call'
|
225
|
+
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
|
226
|
+
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
|
227
|
+
activesupport (6.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
|
228
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
|
229
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/static.rb:24:in `call'
|
230
|
+
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
|
231
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
|
232
|
+
webpacker (5.4.3) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
|
233
|
+
rack-proxy (0.7.2) lib/rack/proxy.rb:67:in `call'
|
234
|
+
railties (6.1.6) lib/rails/engine.rb:539:in `call'
|
235
|
+
puma (5.6.4) lib/puma/configuration.rb:252:in `call'
|
236
|
+
puma (5.6.4) lib/puma/request.rb:77:in `block in handle_request'
|
237
|
+
puma (5.6.4) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
|
238
|
+
puma (5.6.4) lib/puma/request.rb:76:in `handle_request'
|
239
|
+
puma (5.6.4) lib/puma/server.rb:441:in `process_client'
|
240
|
+
puma (5.6.4) lib/puma/thread_pool.rb:147:in `block in spawn_thread'
|
273
241
|
Request
|
274
242
|
Parameters:
|
275
243
|
|
276
|
-
{"id"=>"
|
244
|
+
{"id"=>"2"}
|
277
245
|
Toggle session dump
|
278
246
|
Toggle env dump
|
279
247
|
Response
|
5
エラーの変更、修正後の状態
test
CHANGED
File without changes
|
test
CHANGED
@@ -127,29 +127,90 @@
|
|
127
127
|
```
|
128
128
|
!一通りメッセージ機能が形成できましたら、応募済みの方は再度応募ボタンを押せないようにしたいと考えております。
|
129
129
|
|
130
|
-
|
130
|
+
・plans_controller
|
131
|
-
```
|
131
|
+
```
|
132
|
-
class
|
132
|
+
class PlansController < ApplicationController
|
133
|
-
|
133
|
+
before_action :set_plan, only: [:show, :edit, :update, :destroy ]
|
134
|
+
before_action :require_user_logged_in
|
135
|
+
before_action :current_user, only: [:destroy, :edit, :new]
|
136
|
+
before_action :require_user_logged_in, only: [:edit]
|
137
|
+
before_action :plan_destroy, only: [:show, :index]
|
138
|
+
|
139
|
+
def index
|
134
|
-
|
140
|
+
@pagy, @plans = pagy(Plan.order(id: :desc))
|
141
|
+
end
|
142
|
+
|
143
|
+
def show
|
144
|
+
|
145
|
+
#メッセージ機能の記述
|
146
|
+
@current_entry = Entry.where(user_id: current_user.id)
|
147
|
+
@another_entry = Entry.where(user_id: @plan.user.id)
|
148
|
+
unless @plan.user.id == current_user.id
|
149
|
+
@current_entry.each do |current|
|
150
|
+
@another_entry.each do |another|
|
151
|
+
if current.room_id == another.room_id
|
152
|
+
@is_room = true
|
153
|
+
@room_id = current.room_id
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
unless @is_room
|
158
|
+
@room = Room.new
|
159
|
+
@entry = Entry.new
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
def new
|
166
|
+
@plan = Plan.new
|
167
|
+
if @plan.user == current_user
|
168
|
+
redirect_to '/'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
def create
|
173
|
+
@plan = current_user.plans.build(plan_params)
|
174
|
+
|
175
|
+
if @plan.save
|
176
|
+
flash[:success] = '企画掲載を設定しました'
|
177
|
+
redirect_to root_url
|
178
|
+
else
|
179
|
+
@pagy, @plans = pagy(current_user.plans.order(id: :desc))
|
180
|
+
flash.now[:danger] = '企画掲載に失敗しました'
|
181
|
+
render 'plans/new'
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
def destroy
|
186
|
+
@plan = Plan.find_by(id: params[:id])
|
187
|
+
@plan.destroy
|
188
|
+
flash[:success] = '掲載を中止しました。'
|
189
|
+
redirect_to("/")
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
private
|
194
|
+
def set_plan
|
195
|
+
@plan = Plan.find(params[:id])
|
196
|
+
end
|
197
|
+
|
198
|
+
def plan_params
|
199
|
+
params.require(:plan).permit(:title, :photo, :detail, :start_on, :end_on, :conditions)
|
200
|
+
end
|
201
|
+
|
202
|
+
def plan_destroy
|
203
|
+
Plan.where('end_on < ?', Date.today).destroy_all
|
204
|
+
end
|
205
|
+
|
206
|
+
def correct_user
|
207
|
+
@plan = current_user.plans.find_by(id: params[:id])
|
208
|
+
unless @plan
|
209
|
+
redirect_to root_url
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
135
213
|
end
|
136
|
-
```
|
137
|
-
```
|
138
|
-
class Entry < ApplicationRecord
|
139
|
-
belongs_to :user
|
140
|
-
belongs_to :room
|
141
|
-
end
|
142
|
-
```
|
143
|
-
```
|
144
|
-
class Message < ApplicationRecord
|
145
|
-
belongs_to :user
|
146
|
-
belongs_to :room
|
147
|
-
end
|
148
|
-
```
|
149
|
-
・user.modelのメッセージ記述箇所
|
150
|
-
```
|
151
|
-
has_many :entries, dependent: :destroy
|
152
|
-
has_many :messages, dependent: :destroy
|
153
214
|
```
|
154
215
|
|
155
216
|
私自身で考えてみたのは、rooms.controllerの
|
@@ -180,93 +241,39 @@
|
|
180
241
|
end
|
181
242
|
```
|
182
243
|
|
244
|
+
!修正
|
183
|
-
|
245
|
+
色々と試していたところ、plan/showページの時点で下記のエラーが発生しました。
|
246
|
+
最初の質問時点ではshowは正常に作動し、応募ボタンを押すまではできていたのですが
|
184
|
-
|
247
|
+
plans_controllerのコードを載せたいと思います。
|
185
|
-
|
248
|
+
|
186
|
-
```
|
249
|
+
```
|
250
|
+
ArgumentError in Plans#show
|
251
|
+
Showing /home/ubuntu/environment/tsunageru/app/views/plans/show.html.erb where line #52 raised:
|
252
|
+
|
187
|
-
|
253
|
+
First argument in form cannot contain nil or be empty
|
188
|
-
undefined method `authentication_keys' for User:Class
|
189
|
-
Extracted source (around line #2
|
254
|
+
Extracted source (around line #52):
|
190
|
-
|
255
|
+
50
|
191
|
-
|
256
|
+
51
|
192
|
-
2
|
257
|
+
52
|
193
|
-
|
258
|
+
53
|
194
|
-
|
259
|
+
54
|
195
|
-
|
260
|
+
55
|
196
261
|
|
262
|
+
<p class="user-show-room"><a href="/rooms/<%= @roomId %>" class="btn btn-primary btn-lg">メッセージへ</a>
|
263
|
+
<% else %>
|
264
|
+
<%= form_for @room do |f| %>
|
197
|
-
|
265
|
+
<%= fields_for @entry do |e| %>
|
198
|
-
else
|
199
|
-
super
|
266
|
+
<%= e.hidden_field :user_id, value: @plan.user.id %>
|
200
|
-
end
|
267
|
+
<% end %>
|
201
|
-
end
|
202
|
-
|
203
268
|
|
204
269
|
Rails.root: /home/ubuntu/environment/tsunageru
|
205
270
|
|
206
271
|
Application Trace | Framework Trace | Full Trace
|
207
|
-
activerecord (6.1.6) lib/active_record/dynamic_matchers.rb:22:in `method_missing'
|
208
|
-
devise (4.8.1) lib/devise/failure_app.rb:104:in `i18n_message'
|
209
|
-
devise (4.8.1) lib/devise/failure_app.rb:84:in `redirect'
|
210
|
-
devise (4.8.1) lib/devise/failure_app.rb:43:in `respond'
|
211
|
-
actionpack (6.1.6) lib/abstract_controller/base.rb:228:in `process_action'
|
212
|
-
actionpack (6.1.6) lib/abstract_controller/base.rb:165:in `process'
|
213
|
-
actionpack (6.1.6) lib/action_controller/metal.rb:190:in `dispatch'
|
214
|
-
actionpack (6.1.6) lib/action_controller/metal.rb:238:in `block in action'
|
215
|
-
devise (4.8.1) lib/devise/failure_app.rb:23:in `call'
|
216
|
-
devise (4.8.1) lib/devise/delegator.rb:7:in `call'
|
217
|
-
warden (1.2.9) lib/warden/manager.rb:143:in `call_failure_app'
|
218
|
-
warden (1.2.9) lib/warden/manager.rb:129:in `process_unauthenticated'
|
219
|
-
warden (1.2.9) lib/warden/manager.rb:44:in `call'
|
220
|
-
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
|
221
|
-
|
272
|
+
app/views/plans/show.html.erb:52
|
222
|
-
rack (2.2.3) lib/rack/conditional_get.rb:40:in `call'
|
223
|
-
rack (2.2.3) lib/rack/head.rb:12:in `call'
|
224
|
-
actionpack (6.1.6) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
|
225
|
-
actionpack (6.1.6) lib/action_dispatch/http/content_security_policy.rb:19:in `call'
|
226
|
-
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
|
227
|
-
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
|
228
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/cookies.rb:689:in `call'
|
229
|
-
activerecord (6.1.6) lib/active_record/migration.rb:601:in `call'
|
230
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
|
231
|
-
activesupport (6.1.6) lib/active_support/callbacks.rb:98:in `run_callbacks'
|
232
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
|
233
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
|
234
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
|
235
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
|
236
|
-
web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app'
|
237
|
-
web-console (4.2.0) lib/web_console/middleware.rb:19:in `block in call'
|
238
|
-
web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch'
|
239
|
-
web-console (4.2.0) lib/web_console/middleware.rb:17:in `call'
|
240
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
|
241
|
-
railties (6.1.6) lib/rails/rack/logger.rb:37:in `call_app'
|
242
|
-
railties (6.1.6) lib/rails/rack/logger.rb:26:in `block in call'
|
243
|
-
activesupport (6.1.6) lib/active_support/tagged_logging.rb:99:in `block in tagged'
|
244
|
-
activesupport (6.1.6) lib/active_support/tagged_logging.rb:37:in `tagged'
|
245
|
-
activesupport (6.1.6) lib/active_support/tagged_logging.rb:99:in `tagged'
|
246
|
-
railties (6.1.6) lib/rails/rack/logger.rb:26:in `call'
|
247
|
-
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
|
248
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
|
249
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/request_id.rb:26:in `call'
|
250
|
-
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
|
251
|
-
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
|
252
|
-
activesupport (6.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
|
253
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
|
254
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/static.rb:24:in `call'
|
255
|
-
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
|
256
|
-
actionpack (6.1.6) lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
|
257
|
-
webpacker (5.4.3) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
|
258
|
-
rack-proxy (0.7.2) lib/rack/proxy.rb:67:in `call'
|
259
|
-
railties (6.1.6) lib/rails/engine.rb:539:in `call'
|
260
|
-
puma (5.6.4) lib/puma/configuration.rb:252:in `call'
|
261
|
-
puma (5.6.4) lib/puma/request.rb:77:in `block in handle_request'
|
262
|
-
puma (5.6.4) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
|
263
|
-
puma (5.6.4) lib/puma/request.rb:76:in `handle_request'
|
264
|
-
puma (5.6.4) lib/puma/server.rb:441:in `process_client'
|
265
|
-
puma (5.6.4) lib/puma/thread_pool.rb:147:in `block in spawn_thread'
|
266
273
|
Request
|
267
274
|
Parameters:
|
268
275
|
|
269
|
-
{"
|
276
|
+
{"id"=>"5"}
|
270
277
|
Toggle session dump
|
271
278
|
Toggle env dump
|
272
279
|
Response
|
4
質問のエラー文に対しての修正を行いました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -159,11 +159,6 @@
|
|
159
159
|
```
|
160
160
|
のuser_idをplan.user_idにして、掲載者(plan.user)を特定させなければいけないのかなと思ったのですが、エラーが発生してしまいました。
|
161
161
|
|
162
|
-
・特に聞きたいこと
|
163
|
-
1.上記の参考にしたサイトではユーザーを特定しまし、ユーザーへ直接ルームを作成して、メッセージをやり取りするという流れでしたが、こちらは掲載(plan)で応募して、その掲載者とメッセージでやり取りするという形なのでplanからuserを特定する流れは間違いでしょうか?
|
164
|
-
|
165
|
-
2.エラーに表示されている箇所を発見できないのですが、こちらはRoomsController#createの箇所がエラーという認識であっていますでしょうか?
|
166
|
-
|
167
162
|
説明や解釈が拙い部分が多くあると思いますが、
|
168
163
|
ご指導ご鞭撻のほどよろしくお願いいたします。
|
169
164
|
|
@@ -188,5 +183,95 @@
|
|
188
183
|
ご提案していただいた、rooms_controllerのbefore_action :authenticate_user!を
|
189
184
|
application_controllerへ移してみたのですが、下記のような上記と同じエラーが発生しました。no1knows様のご指摘していただいた、devise周りをもう一度、確認してみたいと思います。
|
190
185
|
もう一つ質問させて頂きたいのですが、掲載(plan)から応募して掲載者(plan.user)と応募者(current_user)のDM(room)を作成するので、DM機能周りのカラムはuser,room以外にplanもreferencesで追加する必要はありでしょうか?
|
186
|
+
```
|
187
|
+
NoMethodError in RoomsController#create
|
188
|
+
undefined method `authentication_keys' for User:Class
|
189
|
+
Extracted source (around line #22):
|
190
|
+
20
|
191
|
+
21
|
192
|
+
22
|
193
|
+
23
|
194
|
+
24
|
195
|
+
25
|
196
|
+
|
197
|
+
send(name, *arguments, &block)
|
198
|
+
else
|
199
|
+
super
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
|
204
|
+
Rails.root: /home/ubuntu/environment/tsunageru
|
205
|
+
|
206
|
+
Application Trace | Framework Trace | Full Trace
|
207
|
+
activerecord (6.1.6) lib/active_record/dynamic_matchers.rb:22:in `method_missing'
|
208
|
+
devise (4.8.1) lib/devise/failure_app.rb:104:in `i18n_message'
|
209
|
+
devise (4.8.1) lib/devise/failure_app.rb:84:in `redirect'
|
210
|
+
devise (4.8.1) lib/devise/failure_app.rb:43:in `respond'
|
211
|
+
actionpack (6.1.6) lib/abstract_controller/base.rb:228:in `process_action'
|
212
|
+
actionpack (6.1.6) lib/abstract_controller/base.rb:165:in `process'
|
213
|
+
actionpack (6.1.6) lib/action_controller/metal.rb:190:in `dispatch'
|
214
|
+
actionpack (6.1.6) lib/action_controller/metal.rb:238:in `block in action'
|
215
|
+
devise (4.8.1) lib/devise/failure_app.rb:23:in `call'
|
216
|
+
devise (4.8.1) lib/devise/delegator.rb:7:in `call'
|
217
|
+
warden (1.2.9) lib/warden/manager.rb:143:in `call_failure_app'
|
218
|
+
warden (1.2.9) lib/warden/manager.rb:129:in `process_unauthenticated'
|
219
|
+
warden (1.2.9) lib/warden/manager.rb:44:in `call'
|
220
|
+
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
|
221
|
+
rack (2.2.3) lib/rack/etag.rb:27:in `call'
|
222
|
+
rack (2.2.3) lib/rack/conditional_get.rb:40:in `call'
|
223
|
+
rack (2.2.3) lib/rack/head.rb:12:in `call'
|
224
|
+
actionpack (6.1.6) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
|
225
|
+
actionpack (6.1.6) lib/action_dispatch/http/content_security_policy.rb:19:in `call'
|
226
|
+
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
|
227
|
+
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
|
228
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/cookies.rb:689:in `call'
|
229
|
+
activerecord (6.1.6) lib/active_record/migration.rb:601:in `call'
|
230
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
|
231
|
+
activesupport (6.1.6) lib/active_support/callbacks.rb:98:in `run_callbacks'
|
232
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
|
233
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
|
234
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
|
235
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
|
236
|
+
web-console (4.2.0) lib/web_console/middleware.rb:132:in `call_app'
|
237
|
+
web-console (4.2.0) lib/web_console/middleware.rb:19:in `block in call'
|
238
|
+
web-console (4.2.0) lib/web_console/middleware.rb:17:in `catch'
|
239
|
+
web-console (4.2.0) lib/web_console/middleware.rb:17:in `call'
|
240
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
|
241
|
+
railties (6.1.6) lib/rails/rack/logger.rb:37:in `call_app'
|
242
|
+
railties (6.1.6) lib/rails/rack/logger.rb:26:in `block in call'
|
243
|
+
activesupport (6.1.6) lib/active_support/tagged_logging.rb:99:in `block in tagged'
|
244
|
+
activesupport (6.1.6) lib/active_support/tagged_logging.rb:37:in `tagged'
|
245
|
+
activesupport (6.1.6) lib/active_support/tagged_logging.rb:99:in `tagged'
|
246
|
+
railties (6.1.6) lib/rails/rack/logger.rb:26:in `call'
|
247
|
+
sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
|
248
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
|
249
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/request_id.rb:26:in `call'
|
250
|
+
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
|
251
|
+
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
|
191
|
-
|
252
|
+
activesupport (6.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
|
192
|
-
|
253
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
|
254
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/static.rb:24:in `call'
|
255
|
+
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
|
256
|
+
actionpack (6.1.6) lib/action_dispatch/middleware/host_authorization.rb:142:in `call'
|
257
|
+
webpacker (5.4.3) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
|
258
|
+
rack-proxy (0.7.2) lib/rack/proxy.rb:67:in `call'
|
259
|
+
railties (6.1.6) lib/rails/engine.rb:539:in `call'
|
260
|
+
puma (5.6.4) lib/puma/configuration.rb:252:in `call'
|
261
|
+
puma (5.6.4) lib/puma/request.rb:77:in `block in handle_request'
|
262
|
+
puma (5.6.4) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
|
263
|
+
puma (5.6.4) lib/puma/request.rb:76:in `handle_request'
|
264
|
+
puma (5.6.4) lib/puma/server.rb:441:in `process_client'
|
265
|
+
puma (5.6.4) lib/puma/thread_pool.rb:147:in `block in spawn_thread'
|
266
|
+
Request
|
267
|
+
Parameters:
|
268
|
+
|
269
|
+
{"authenticity_token"=>"[FILTERED]", "entry"=>{"user_id"=>"4"}, "commit"=>"応募する"}
|
270
|
+
Toggle session dump
|
271
|
+
Toggle env dump
|
272
|
+
Response
|
273
|
+
Headers:
|
274
|
+
|
275
|
+
None
|
276
|
+
```
|
277
|
+
|
3
修正と、追加の質問
test
CHANGED
File without changes
|
test
CHANGED
@@ -185,4 +185,8 @@
|
|
185
185
|
end
|
186
186
|
```
|
187
187
|
|
188
|
+
ご提案していただいた、rooms_controllerのbefore_action :authenticate_user!を
|
189
|
+
application_controllerへ移してみたのですが、下記のような上記と同じエラーが発生しました。no1knows様のご指摘していただいた、devise周りをもう一度、確認してみたいと思います。
|
190
|
+
もう一つ質問させて頂きたいのですが、掲載(plan)から応募して掲載者(plan.user)と応募者(current_user)のDM(room)を作成するので、DM機能周りのカラムはuser,room以外にplanもreferencesで追加する必要はありでしょうか?
|
191
|
+

|
188
192
|
|
2
質問の内容の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
下記のサイトをうまく活用して、掲載物に応募ボタンを行うと掲載者とメッセージ機能でやり取りができるようにしたいと思っているのですが、掲載物の閲覧ページ(view/plans/show)に応募ボタンを設置してみたのですが、エラーが発生しました。
|
1
|
+
下記のサイトをうまく活用して、掲載物に応募ボタンを行うと掲載者とメッセージ機能でやり取りができるようにしたいと思っているのですが、掲載物の閲覧ページ(view/plans/show)に応募ボタンを設置してみたのですが、応募ボタンをクリック後にエラーが発生しました。
|
2
2
|
https://qiita.com/bindingpry/items/6790c91f374acc25bea2
|
3
3
|
https://qiita.com/aaaasahi_17/items/9e7f344488c720aaf116
|
4
4
|
|
1
画像の修正、説明の足りない箇所の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
https://qiita.com/bindingpry/items/6790c91f374acc25bea2
|
3
3
|
https://qiita.com/aaaasahi_17/items/9e7f344488c720aaf116
|
4
4
|
|
5
|
-
|
5
|
+
!修正しました。
|
6
|
-

|
7
7
|
|
8
8
|
エラーが発生したファイルがこちらです。
|
9
9
|
・RoomsController
|
@@ -167,5 +167,22 @@
|
|
167
167
|
説明や解釈が拙い部分が多くあると思いますが、
|
168
168
|
ご指導ご鞭撻のほどよろしくお願いいたします。
|
169
169
|
|
170
|
+
・追加
|
171
|
+
application_controller
|
172
|
+
```
|
173
|
+
class ApplicationController < ActionController::Base
|
174
|
+
|
175
|
+
include SessionsHelper
|
176
|
+
include Pagy::Backend
|
177
|
+
|
178
|
+
private
|
179
|
+
|
180
|
+
def require_user_logged_in
|
181
|
+
unless logged_in?
|
182
|
+
redirect_to login_url
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
```
|
170
187
|
|
171
188
|
|