質問編集履歴
10
質問の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,58 +8,28 @@
|
|
8
8
|
と記述しuser_idを取得しようとしました。
|
9
9
|
|
10
10
|
4.ルームの中にあるuser_idはEntryからとってくると思っているのだが正しいかは不明
|
11
|
-
|
11
|
+
!追記
|
12
|
+
関連定義を見直し、退会を行おうとしたところエラーが発生しました。
|
12
13
|
### 発生している問題・エラーメッセージ
|
13
14
|
|
14
15
|
```
|
15
|
-
ActiveRecord::
|
16
|
-
|
17
|
-
|
18
|
-
Request info
|
19
|
-
Request parameters
|
20
|
-
{"_method"=>"patch", "authenticity_token"=>"UZ2GRuhk2UDrRppZKpuipE8m4mND7U2-EnRhRaK8tHyzxAc_pI5vvIvo-U6CdKkjDWXD1RFLFbC6hsBgB6Eb6Q", "controller"=>"users", "action"=>"withdrawal", "id"=>"2"}
|
21
|
-
Rack session
|
22
|
-
#<ActionDispatch::Request::Session:0x00007f9a5c087b10 @by=#<ActionDispatch::Session::CookieStore:0x0000564c8424b018 @app=#<ActionDispatch::ContentSecurityPolicy::Middleware:0x0000564c8424b388 @app=#<ActionDispatch::PermissionsPolicy::Middleware:0x0000564c8424b478 @app=#<Rack::Head:0x0000564c8424b5b8 @app=#<Rack::ConditionalGet:0x0000564c8424b810 @app=#<Rack::ETag:0x0000564c8424b900 @app=#<Rack::TempfileReaper:0x0000564c8424ba18 @app=#<Warden::Manager:0x0000564c84250310 @config={:default_scope=>:user, :scope_defaults=>{}, :default_strategies=>{:user=>[:rememberable, :database_authenticatable]}, :intercept_401=>false, :failure_app=>#<Devise::Delegator:0x0000564c84238850>}, @app=#<ActionDispatch::Routing::RouteSet:0x0000564c83ede178>>>, @cache_control="max-age=0, private, must-revalidate", @no_cache_control="no-cache">>>>>, @default_options={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false}, @key="_tsunageru_session", @cookie_only=true, @same_site=nil>, @req=#<ActionDispatch::Request POST "https://f3c5ff7c750c474ba358523266e7506d.vfs.cloud9.ap-northeast-1.amazonaws.com/users/2/withdrawal" for 113.149.158.1>, @delegate={"session_id"=>"f644274634279a20a5991273e664f31d", "warden.user.user.key"=>[[2], "$2a$12$eWuHm5yX5ZAWfOfk0wOsSu"], "flash"=>{"discard"=>[], "flashes"=>{"notice"=>"アカウント情報を変更しました。"}}, "_csrf_token"=>"bWTxXFfF6fPCLjMwhSG6VKwoejCCxgAPrDY1aZnw5qs="}, @loaded=true, @exists=true>
|
23
|
-
Local Variables
|
24
|
-
Instance Variables
|
25
|
-
@_action_has_layout
|
26
|
-
true
|
27
|
-
@rendered_format
|
28
|
-
nil
|
29
|
-
@_routes
|
30
|
-
nil
|
31
|
-
@_request
|
32
|
-
(Instance of ignored class. Remove ActionDispatch::Request from BetterErrors.ignored_classes if you need to see it.)
|
33
|
-
@_response
|
34
|
-
(Instance of ignored class. Remove ActionDispatch::Response from BetterErrors.ignored_classes if you need to see it.)
|
35
|
-
@_lookup_context
|
36
|
-
#<ActionView::LookupContext:0x00007f9a5c0862b0 @details_key=nil, @digest_cache=nil, @cache=true, @prefixes=["users", "application"], @details={:locale=>[:ja], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}, @view_paths=#<ActionView::PathSet:0x00007f9a5c0861c0 @paths=[#<ActionView::OptimizedFileSystemResolver:0x0000564c854ac1a8 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000564c854ac158 entries=7 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x00007f9a5c06c040 @regex=/ \A (?:(?<prefix>.*)\/)? (?<partial>_)? (?<action>.*?) (?:\.(?<locale>[a-z]{2}(?:-[A-Z]{2})?))?? (?:\.(?<format>html|text|js|css|ics|csv|vcf|vtt|png|jpeg|gif|bmp|tiff|svg|mpeg|mp3|ogg|m4a|webm|mp4|otf|ttf|woff|woff2|xml|rss|atom|yaml|multipart_form|url_encoded_form|json|pdf|zip|gzip))?? (?:\+(?<variant>[^.]*))?? (?:\.(?<handler>raw|erb|html|builder|ruby|jbuilder))? \z /x>, @cache=#<ActionView::Resolver::Cache:0x0000564c854ac018 keys=2 queries=0>, @path="/home/ubuntu/environment/tsunageru/app/views">, #<ActionView::OptimizedFileSystemResolver:0x0000564c854ac6a8 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000564c854ac658 entries=1 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x00007f9a5c06c018 @regex=/ \A (?:(?<prefix>.*)\/)? (?<partial>_)? (?<action>.*?) (?:\.(?<locale>[a-z]{2}(?:-[A-Z]{2})?))?? (?:\.(?<format>html|text|js|css|ics|csv|vcf|vtt|png|jpeg|gif|bmp|tiff|svg|mpeg|mp3|ogg|m4a|webm|mp4|otf|ttf|woff|woff2|xml|rss|atom|yaml|multipart_form|url_encoded_form|json|pdf|zip|gzip))?? (?:\+(?<variant>[^.]*))?? (?:\.(?<handler>raw|erb|html|builder|ruby|jbuilder))? \z /x>, @cache=#<ActionView::Resolver::Cache:0x0000564c854ac590 keys=2 queries=0>, @path="/home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-i18n-1.10.2/app/views">, #<ActionView::OptimizedFileSystemResolver:0x0000564c854ace00 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000564c854acdb0 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x00007f9a5c067fb8>, @cache=#<ActionView::Resolver::Cache:0x0000564c854acc98 keys=1 queries=0>, @path="/home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/app/views">]>>
|
37
|
-
@_action_name
|
38
|
-
"withdrawal"
|
39
|
-
@_response_body
|
40
|
-
nil
|
41
|
-
@marked_for_same_origin_verification
|
42
|
-
false
|
43
|
-
@_config
|
44
|
-
#< {}>
|
45
|
-
@_params
|
46
|
-
#<ActionController::Parameters {"_method"=>"patch", "authenticity_token"=>"UZ2GRuhk2UDrRppZKpuipE8m4mND7U2-EnRhRaK8tHyzxAc_pI5vvIvo-U6CdKkjDWXD1RFLFbC6hsBgB6Eb6Q", "controller"=>"users", "action"=>"withdrawal", "id"=>"2"} permitted: false>
|
47
|
-
@user
|
48
|
-
(exception ArgumentError was raised in inspect)
|
49
|
-
@current_user
|
50
|
-
(exception ArgumentError was raised in inspect)
|
51
|
-
@currentUserEntry
|
52
|
-
#<ActiveRecord::Relation [#<Entry id: 1, user_id: 2, room_id: 1>, #<Entry id: 3, user_id: 2, room_id: 2>]>
|
16
|
+
ActiveRecord::HasManyThroughOrderError at /users/3/withdrawal
|
17
|
+
Cannot have a has_many :through association 'User#rooms' which goes through 'User#entries' before the through association is defined.
|
53
18
|
```
|
54
19
|
|
20
|
+
```
|
21
|
+
def withdrawal
|
22
|
+
@user = User.find(params[:id])
|
23
|
+
@user.destroy ←エラー箇所
|
24
|
+
flash[:notice] = 'ユーザーを削除しました。'
|
25
|
+
redirect_to '/'
|
26
|
+
end
|
27
|
+
```
|
55
28
|
### 該当のソースコード
|
56
29
|
恐らく関連している箇所はuserのコントローラとモデルの2つです。
|
57
30
|
```users_controller.rb/withdrawalアクション
|
58
31
|
def withdrawal
|
59
|
-
@room = Room.all
|
60
32
|
@user = User.find(params[:id])
|
61
|
-
@currentUserEntry=Entry.where(user_id: current_user.id)
|
62
|
-
@room.destroy
|
63
33
|
@user.destroy
|
64
34
|
flash[:notice] = 'ユーザーを削除しました。'
|
65
35
|
redirect_to '/'
|
@@ -74,6 +44,8 @@
|
|
74
44
|
has_many :followers, through: :reverses_of_relationship, source: :user, :dependent => :destroy
|
75
45
|
has_many :favorites, :dependent => :destroy
|
76
46
|
has_many :favorite_plans, through: :favorites, source: :plan, :dependent => :destroy
|
47
|
+
has_many :rooms, through: :entries
|
48
|
+
has_many :rooms, through: :entries, :dependent => :destroy
|
77
49
|
has_many :entries, :dependent => :destroy
|
78
50
|
has_many :messages, :dependent => :destroy
|
79
51
|
```
|
@@ -113,6 +85,8 @@
|
|
113
85
|
has_many :entries, dependent: :destroy
|
114
86
|
has_many :messages, dependent: :destroy
|
115
87
|
belongs_to :plan
|
88
|
+
has_many :users, through: :entries
|
89
|
+
has_many :users, through: :entries, :dependent => :destroy
|
116
90
|
end
|
117
91
|
|
118
92
|
```
|
9
コードの更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,9 +56,11 @@
|
|
56
56
|
恐らく関連している箇所はuserのコントローラとモデルの2つです。
|
57
57
|
```users_controller.rb/withdrawalアクション
|
58
58
|
def withdrawal
|
59
|
+
@room = Room.all
|
59
60
|
@user = User.find(params[:id])
|
60
61
|
@currentUserEntry=Entry.where(user_id: current_user.id)
|
62
|
+
@room.destroy
|
61
|
-
@user.destroy
|
63
|
+
@user.destroy
|
62
64
|
flash[:notice] = 'ユーザーを削除しました。'
|
63
65
|
redirect_to '/'
|
64
66
|
end
|
8
コードの更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -130,11 +130,7 @@
|
|
130
130
|
<div class = 'dm-list'>
|
131
131
|
<% @rooms.zip(@anotherEntries) do |room,entry| %>
|
132
132
|
<div style='width: 200px; border:solid 1px gray'>
|
133
|
-
<% unless @anotherEntries == nil %>
|
134
|
-
<p><%= link_to entry.user.name, user_path(entry.user), class: "text-decoration-none" %></p>
|
133
|
+
<p><%= link_to entry.user.name, user_path(entry.user), class: "text-decoration-none" %></p>
|
135
|
-
<% else %>
|
136
|
-
<p>退会済のユーザー</p>
|
137
|
-
<% end %>
|
138
134
|
<p><%= link_to room.room_name, plan_path(room.plan_id), class: "text-decoration-none" %></p>
|
139
135
|
<p><%= link_to 'メッセージ', room, class: "btn btn-primary btn-lg" %></p>
|
140
136
|
</div><br />
|
7
コードの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -125,4 +125,24 @@
|
|
125
125
|
退会処理が行われるとユーザーはアカウントを使用できなくなります。
|
126
126
|
ただし、データ自体は記憶媒体(データベース)には存在します。
|
127
127
|
|
128
|
+
!追記 コードの追記
|
129
|
+
```_room.html.erb
|
130
|
+
<div class = 'dm-list'>
|
131
|
+
<% @rooms.zip(@anotherEntries) do |room,entry| %>
|
132
|
+
<div style='width: 200px; border:solid 1px gray'>
|
133
|
+
<% unless @anotherEntries == nil %>
|
134
|
+
<p><%= link_to entry.user.name, user_path(entry.user), class: "text-decoration-none" %></p> ←この箇所
|
135
|
+
<% else %>
|
136
|
+
<p>退会済のユーザー</p>
|
137
|
+
<% end %>
|
138
|
+
<p><%= link_to room.room_name, plan_path(room.plan_id), class: "text-decoration-none" %></p>
|
139
|
+
<p><%= link_to 'メッセージ', room, class: "btn btn-primary btn-lg" %></p>
|
140
|
+
</div><br />
|
141
|
+
<% end %>
|
142
|
+
<div class="d-flex justify-content-left mb-2">
|
143
|
+
<%== pagy_bootstrap_nav(@pagy) %>
|
144
|
+
</div>
|
145
|
+
</div>
|
128
146
|
|
147
|
+
```
|
148
|
+
|
6
コードの更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -74,7 +74,6 @@
|
|
74
74
|
has_many :favorite_plans, through: :favorites, source: :plan, :dependent => :destroy
|
75
75
|
has_many :entries, :dependent => :destroy
|
76
76
|
has_many :messages, :dependent => :destroy
|
77
|
-
has_many :rooms, :dependent => :destroy
|
78
77
|
```
|
79
78
|
!追記
|
80
79
|
```schema/roomsandUsers
|
@@ -111,7 +110,6 @@
|
|
111
110
|
class Room < ApplicationRecord
|
112
111
|
has_many :entries, dependent: :destroy
|
113
112
|
has_many :messages, dependent: :destroy
|
114
|
-
has_many :users, dependent: :destroy
|
115
113
|
belongs_to :plan
|
116
114
|
end
|
117
115
|
|
5
コードの更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -107,7 +107,15 @@
|
|
107
107
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
108
108
|
end
|
109
109
|
```
|
110
|
+
```room.rb
|
111
|
+
class Room < ApplicationRecord
|
112
|
+
has_many :entries, dependent: :destroy
|
113
|
+
has_many :messages, dependent: :destroy
|
114
|
+
has_many :users, dependent: :destroy
|
115
|
+
belongs_to :plan
|
116
|
+
end
|
110
117
|
|
118
|
+
```
|
111
119
|
箇条書きで簡潔に書こうと試みてみたのですが、うまく伝わっていませんでしたらすみません。
|
112
120
|
|
113
121
|
!追記
|
4
コードの更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -77,13 +77,34 @@
|
|
77
77
|
has_many :rooms, :dependent => :destroy
|
78
78
|
```
|
79
79
|
!追記
|
80
|
-
```schema/rooms
|
80
|
+
```schema/roomsandUsers
|
81
81
|
create_table "rooms", charset: "utf8mb4", force: :cascade do |t|
|
82
82
|
t.string "room_name"
|
83
83
|
t.datetime "created_at", precision: 6, null: false
|
84
84
|
t.datetime "updated_at", precision: 6, null: false
|
85
85
|
t.bigint "plan_id", null: false
|
86
86
|
t.index ["plan_id"], name: "index_rooms_on_plan_id"
|
87
|
+
end
|
88
|
+
|
89
|
+
create_table "users", charset: "utf8mb4", force: :cascade do |t|
|
90
|
+
t.string "email", default: "", null: false
|
91
|
+
t.string "encrypted_password", default: "", null: false
|
92
|
+
t.string "name", null: false
|
93
|
+
t.string "furiganaName", null: false
|
94
|
+
t.string "password_digest", default: "", null: false
|
95
|
+
t.string "telephone_number", null: false
|
96
|
+
t.string "post_code", null: false
|
97
|
+
t.string "address", null: false
|
98
|
+
t.string "self_introduction"
|
99
|
+
t.string "image"
|
100
|
+
t.string "reset_password_token"
|
101
|
+
t.datetime "reset_password_sent_at"
|
102
|
+
t.datetime "remember_created_at"
|
103
|
+
t.datetime "created_at", precision: 6, null: false
|
104
|
+
t.datetime "updated_at", precision: 6, null: false
|
105
|
+
t.boolean "is_deleted", default: true, null: false
|
106
|
+
t.index ["email"], name: "index_users_on_email", unique: true
|
107
|
+
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
87
108
|
end
|
88
109
|
```
|
89
110
|
|
3
情報の更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,8 +14,43 @@
|
|
14
14
|
```
|
15
15
|
ActiveRecord::StatementInvalid at /users/2/withdrawal
|
16
16
|
Mysql2::Error: Unknown column 'rooms.user_id' in 'where clause'
|
17
|
+
|
18
|
+
Request info
|
19
|
+
Request parameters
|
20
|
+
{"_method"=>"patch", "authenticity_token"=>"UZ2GRuhk2UDrRppZKpuipE8m4mND7U2-EnRhRaK8tHyzxAc_pI5vvIvo-U6CdKkjDWXD1RFLFbC6hsBgB6Eb6Q", "controller"=>"users", "action"=>"withdrawal", "id"=>"2"}
|
21
|
+
Rack session
|
22
|
+
#<ActionDispatch::Request::Session:0x00007f9a5c087b10 @by=#<ActionDispatch::Session::CookieStore:0x0000564c8424b018 @app=#<ActionDispatch::ContentSecurityPolicy::Middleware:0x0000564c8424b388 @app=#<ActionDispatch::PermissionsPolicy::Middleware:0x0000564c8424b478 @app=#<Rack::Head:0x0000564c8424b5b8 @app=#<Rack::ConditionalGet:0x0000564c8424b810 @app=#<Rack::ETag:0x0000564c8424b900 @app=#<Rack::TempfileReaper:0x0000564c8424ba18 @app=#<Warden::Manager:0x0000564c84250310 @config={:default_scope=>:user, :scope_defaults=>{}, :default_strategies=>{:user=>[:rememberable, :database_authenticatable]}, :intercept_401=>false, :failure_app=>#<Devise::Delegator:0x0000564c84238850>}, @app=#<ActionDispatch::Routing::RouteSet:0x0000564c83ede178>>>, @cache_control="max-age=0, private, must-revalidate", @no_cache_control="no-cache">>>>>, @default_options={:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :defer=>false, :renew=>false}, @key="_tsunageru_session", @cookie_only=true, @same_site=nil>, @req=#<ActionDispatch::Request POST "https://f3c5ff7c750c474ba358523266e7506d.vfs.cloud9.ap-northeast-1.amazonaws.com/users/2/withdrawal" for 113.149.158.1>, @delegate={"session_id"=>"f644274634279a20a5991273e664f31d", "warden.user.user.key"=>[[2], "$2a$12$eWuHm5yX5ZAWfOfk0wOsSu"], "flash"=>{"discard"=>[], "flashes"=>{"notice"=>"アカウント情報を変更しました。"}}, "_csrf_token"=>"bWTxXFfF6fPCLjMwhSG6VKwoejCCxgAPrDY1aZnw5qs="}, @loaded=true, @exists=true>
|
23
|
+
Local Variables
|
24
|
+
Instance Variables
|
25
|
+
@_action_has_layout
|
26
|
+
true
|
27
|
+
@rendered_format
|
28
|
+
nil
|
29
|
+
@_routes
|
30
|
+
nil
|
31
|
+
@_request
|
32
|
+
(Instance of ignored class. Remove ActionDispatch::Request from BetterErrors.ignored_classes if you need to see it.)
|
33
|
+
@_response
|
34
|
+
(Instance of ignored class. Remove ActionDispatch::Response from BetterErrors.ignored_classes if you need to see it.)
|
35
|
+
@_lookup_context
|
36
|
+
#<ActionView::LookupContext:0x00007f9a5c0862b0 @details_key=nil, @digest_cache=nil, @cache=true, @prefixes=["users", "application"], @details={:locale=>[:ja], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}, @view_paths=#<ActionView::PathSet:0x00007f9a5c0861c0 @paths=[#<ActionView::OptimizedFileSystemResolver:0x0000564c854ac1a8 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000564c854ac158 entries=7 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x00007f9a5c06c040 @regex=/ \A (?:(?<prefix>.*)\/)? (?<partial>_)? (?<action>.*?) (?:\.(?<locale>[a-z]{2}(?:-[A-Z]{2})?))?? (?:\.(?<format>html|text|js|css|ics|csv|vcf|vtt|png|jpeg|gif|bmp|tiff|svg|mpeg|mp3|ogg|m4a|webm|mp4|otf|ttf|woff|woff2|xml|rss|atom|yaml|multipart_form|url_encoded_form|json|pdf|zip|gzip))?? (?:\+(?<variant>[^.]*))?? (?:\.(?<handler>raw|erb|html|builder|ruby|jbuilder))? \z /x>, @cache=#<ActionView::Resolver::Cache:0x0000564c854ac018 keys=2 queries=0>, @path="/home/ubuntu/environment/tsunageru/app/views">, #<ActionView::OptimizedFileSystemResolver:0x0000564c854ac6a8 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000564c854ac658 entries=1 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x00007f9a5c06c018 @regex=/ \A (?:(?<prefix>.*)\/)? (?<partial>_)? (?<action>.*?) (?:\.(?<locale>[a-z]{2}(?:-[A-Z]{2})?))?? (?:\.(?<format>html|text|js|css|ics|csv|vcf|vtt|png|jpeg|gif|bmp|tiff|svg|mpeg|mp3|ogg|m4a|webm|mp4|otf|ttf|woff|woff2|xml|rss|atom|yaml|multipart_form|url_encoded_form|json|pdf|zip|gzip))?? (?:\+(?<variant>[^.]*))?? (?:\.(?<handler>raw|erb|html|builder|ruby|jbuilder))? \z /x>, @cache=#<ActionView::Resolver::Cache:0x0000564c854ac590 keys=2 queries=0>, @path="/home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-i18n-1.10.2/app/views">, #<ActionView::OptimizedFileSystemResolver:0x0000564c854ace00 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @unbound_templates=#<Concurrent::Map:0x0000564c854acdb0 entries=0 default_proc=nil>, @path_parser=#<ActionView::Resolver::PathParser:0x00007f9a5c067fb8>, @cache=#<ActionView::Resolver::Cache:0x0000564c854acc98 keys=1 queries=0>, @path="/home/ubuntu/.rvm/gems/ruby-3.0.0/gems/devise-4.8.1/app/views">]>>
|
37
|
+
@_action_name
|
38
|
+
"withdrawal"
|
39
|
+
@_response_body
|
40
|
+
nil
|
41
|
+
@marked_for_same_origin_verification
|
42
|
+
false
|
43
|
+
@_config
|
44
|
+
#< {}>
|
45
|
+
@_params
|
46
|
+
#<ActionController::Parameters {"_method"=>"patch", "authenticity_token"=>"UZ2GRuhk2UDrRppZKpuipE8m4mND7U2-EnRhRaK8tHyzxAc_pI5vvIvo-U6CdKkjDWXD1RFLFbC6hsBgB6Eb6Q", "controller"=>"users", "action"=>"withdrawal", "id"=>"2"} permitted: false>
|
47
|
+
@user
|
48
|
+
(exception ArgumentError was raised in inspect)
|
49
|
+
@current_user
|
50
|
+
(exception ArgumentError was raised in inspect)
|
51
|
+
@currentUserEntry
|
52
|
+
#<ActiveRecord::Relation [#<Entry id: 1, user_id: 2, room_id: 1>, #<Entry id: 3, user_id: 2, room_id: 2>]>
|
17
53
|
```
|
18
|
-

|
19
54
|
|
20
55
|
### 該当のソースコード
|
21
56
|
恐らく関連している箇所はuserのコントローラとモデルの2つです。
|
@@ -41,6 +76,16 @@
|
|
41
76
|
has_many :messages, :dependent => :destroy
|
42
77
|
has_many :rooms, :dependent => :destroy
|
43
78
|
```
|
79
|
+
!追記
|
80
|
+
```schema/rooms
|
81
|
+
create_table "rooms", charset: "utf8mb4", force: :cascade do |t|
|
82
|
+
t.string "room_name"
|
83
|
+
t.datetime "created_at", precision: 6, null: false
|
84
|
+
t.datetime "updated_at", precision: 6, null: false
|
85
|
+
t.bigint "plan_id", null: false
|
86
|
+
t.index ["plan_id"], name: "index_rooms_on_plan_id"
|
87
|
+
end
|
88
|
+
```
|
44
89
|
|
45
90
|
箇条書きで簡潔に書こうと試みてみたのですが、うまく伝わっていませんでしたらすみません。
|
46
91
|
|
2
情報の更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
ActiveRecord::StatementInvalid at /users/2/withdrawal
|
16
16
|
Mysql2::Error: Unknown column 'rooms.user_id' in 'where clause'
|
17
17
|
```
|
18
|
+

|
18
19
|
|
19
20
|
### 該当のソースコード
|
20
21
|
恐らく関連している箇所はuserのコントローラとモデルの2つです。
|
@@ -22,7 +23,7 @@
|
|
22
23
|
def withdrawal
|
23
24
|
@user = User.find(params[:id])
|
24
25
|
@currentUserEntry=Entry.where(user_id: current_user.id)
|
25
|
-
@user.destroy
|
26
|
+
@user.destroy ←エラー箇所
|
26
27
|
flash[:notice] = 'ユーザーを削除しました。'
|
27
28
|
redirect_to '/'
|
28
29
|
end
|
1
情報の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -43,3 +43,13 @@
|
|
43
43
|
|
44
44
|
箇条書きで簡潔に書こうと試みてみたのですが、うまく伝わっていませんでしたらすみません。
|
45
45
|
|
46
|
+
!追記
|
47
|
+
・物理削除
|
48
|
+
退会処理が行われるとユーザーはアカウントを使用できなくなります。
|
49
|
+
そして、データ自体も記憶媒体(データベース)から削除されます。
|
50
|
+
|
51
|
+
・論理削除
|
52
|
+
退会処理が行われるとユーザーはアカウントを使用できなくなります。
|
53
|
+
ただし、データ自体は記憶媒体(データベース)には存在します。
|
54
|
+
|
55
|
+
|