質問編集履歴

6

文章の修正

2021/09/11 09:52

投稿

Taka2401
Taka2401

スコア8

test CHANGED
File without changes
test CHANGED
@@ -20,53 +20,109 @@
20
20
 
21
21
 
22
22
 
23
- web_1 | ActionController::RoutingError (uninitialized constant Api::V1::RelationshipsController):
23
+ web_1 | Processing by Api::V1::RelationshipsController#create as JSON
24
+
25
+ web_1 | Parameters: {"followed_id"=>1, "relationship"=>{"followed_id"=>1}}
26
+
27
+ web_1 | User Load (0.4ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1
28
+
29
+ web_1 | ↳ /usr/local/bundle/gems/activerecord-5.2.6/lib/active_record/log_subscriber.rb:98
30
+
31
+ web_1 | (0.2ms) BEGIN
32
+
33
+ web_1 | ↳ app/models/user.rb:26
34
+
35
+ web_1 | User Load (0.3ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 LIMIT 1
36
+
37
+ web_1 | ↳ app/models/user.rb:26
38
+
39
+ web_1 | (0.3ms) ROLLBACK
40
+
41
+ web_1 | ↳ app/models/user.rb:26
42
+
43
+ web_1 | Completed 201 Created in 8ms (ActiveRecord: 1.1ms)
24
44
 
25
45
  web_1 |
26
46
 
27
- web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:285:in `const_get'
47
+ web_1 |
28
-
48
+
29
- web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:285:in `block in constantize'
49
+ web_1 | Started GET "/api/v1/relationships/?followed_id=1" for 172.24.0.1 at 2021-09-11 09:46:32 +0000
30
-
50
+
31
- web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:281:in `each'
51
+ web_1 | Cannot render console from 172.24.0.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
32
-
52
+
33
- web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:281:in `inject'
53
+ web_1 |
34
-
35
- web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:281:in `constantize'
54
+
36
-
37
- web_1 | actionpack (5.2.6) lib/action_dispatch/http/request.rb:88:in `controller_class_for'
38
-
39
- web_1 | actionpack (5.2.6) lib/action_dispatch/http/request.rb:81:in `controller_class'
55
+ web_1 | ActionController::RoutingError (No route matches [GET] "/api/v1/relationships"):
40
-
56
+
41
- web_1 | actionpack (5.2.6) lib/action_dispatch/routing/route_set.rb:46:in `controller'
57
+ web_1 |
42
-
58
+
43
- web_1 | actionpack (5.2.6) lib/action_dispatch/routing/route_set.rb:32:in `serve'
59
+ web_1 | actionpack (5.2.6) lib/action_dispatch/middleware/debug_exceptions.rb:65:in `call'
60
+
44
-
61
+ web_1 | web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
62
+
45
- web_1 | actionpack (5.2.6) lib/action_dispatch/journey/router.rb:52:in `block in serve'
63
+ web_1 | web-console (3.7.0) lib/web_console/middleware.rb:22:in `block in call'
64
+
46
-
65
+ web_1 | web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
66
+
67
+ web_1 | web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
68
+
47
- web_1 | actionpack (5.2.6) lib/action_dispatch/journey/router.rb:35:in `each'
69
+ web_1 | actionpack (5.2.6) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
70
+
48
-
71
+ web_1 | railties (5.2.6) lib/rails/rack/logger.rb:38:in `call_app'
72
+
73
+ web_1 | railties (5.2.6) lib/rails/rack/logger.rb:26:in `block in call'
74
+
75
+ web_1 | activesupport (5.2.6) lib/active_support/tagged_logging.rb:71:in `block in tagged'
76
+
77
+ web_1 | activesupport (5.2.6) lib/active_support/tagged_logging.rb:28:in `tagged'
78
+
79
+ web_1 | activesupport (5.2.6) lib/active_support/tagged_logging.rb:71:in `tagged'
80
+
49
- web_1 | actionpack (5.2.6) lib/action_dispatch/journey/router.rb:35:in `serve'
81
+ web_1 | railties (5.2.6) lib/rails/rack/logger.rb:26:in `call'
82
+
50
-
83
+ web_1 | sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
84
+
51
- web_1 | actionpack (5.2.6) lib/action_dispatch/routing/route_set.rb:840:in `call'
85
+ web_1 | actionpack (5.2.6) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
86
+
52
-
87
+ web_1 | actionpack (5.2.6) lib/action_dispatch/middleware/request_id.rb:27:in `call'
88
+
89
+ web_1 | rack (2.2.3) lib/rack/method_override.rb:24:in `call'
90
+
91
+ web_1 | rack (2.2.3) lib/rack/runtime.rb:22:in `call'
92
+
93
+ web_1 | activesupport (5.2.6) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
94
+
95
+ web_1 | actionpack (5.2.6) lib/action_dispatch/middleware/executor.rb:14:in `call'
96
+
97
+ web_1 | actionpack (5.2.6) lib/action_dispatch/middleware/static.rb:127:in `call'
98
+
99
+ web_1 | rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
100
+
101
+ web_1 | webpacker (5.4.2) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
102
+
103
+ web_1 | rack-proxy (0.7.0) lib/rack/proxy.rb:63:in `call'
104
+
53
- web_1 | bullet (6.1.4) lib/bullet/rack.rb:15:in `call'
105
+ web_1 | railties (5.2.6) lib/rails/engine.rb:524:in `call'
106
+
107
+ web_1 | puma (3.12.6) lib/puma/configuration.rb:227:in `call'
108
+
109
+ web_1 | puma (3.12.6) lib/puma/server.rb:706:in `handle_request'
110
+
111
+ web_1 | puma (3.12.6) lib/puma/server.rb:476:in `process_client'
112
+
113
+ web_1 | puma (3.12.6) lib/puma/server.rb:334:in `block in run'
114
+
115
+ web_1 | puma (3.12.6) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
54
116
 
55
117
  ```
56
118
 
57
119
  ```cocnsole
58
120
 
59
- xhr.js:184 POST http://localhost:3000/api/v1/relationships 404 (Not Found)
121
+ xhr.js:184 GET http://localhost:3000/api/v1/relationships/?followed_id=1 404 (Not Found)
60
-
61
- vue.esm.js:648 [Vue warn]: Error in v-on handler (Promise/async): "Error: Request failed with status code 404"
122
+
62
-
63
- found in
123
+
64
-
65
- ---> <RelationshipButton> at app/javascript/components/RelationshipButton.vue
124
+
66
-
67
- <Root>
68
-
69
- vue.esm.js:1946 Error: Request failed with status code 404
125
+ createError.js:17 Uncaught (in promise) Error: Request failed with status code 404
70
126
 
71
127
  at createError (createError.js:17)
72
128
 

5

文章の修正

2021/09/11 09:52

投稿

Taka2401
Taka2401

スコア8

test CHANGED
File without changes
test CHANGED
@@ -12,15 +12,47 @@
12
12
 
13
13
  axiosを使い、postを実行したところ404エラーが出ました。
14
14
 
15
+
16
+
15
17
  ```
16
18
 
17
19
  //エラーログ
18
20
 
19
21
 
20
22
 
23
+ web_1 | ActionController::RoutingError (uninitialized constant Api::V1::RelationshipsController):
24
+
25
+ web_1 |
26
+
27
+ web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:285:in `const_get'
28
+
29
+ web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:285:in `block in constantize'
30
+
31
+ web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:281:in `each'
32
+
33
+ web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:281:in `inject'
34
+
35
+ web_1 | activesupport (5.2.6) lib/active_support/inflector/methods.rb:281:in `constantize'
36
+
37
+ web_1 | actionpack (5.2.6) lib/action_dispatch/http/request.rb:88:in `controller_class_for'
38
+
39
+ web_1 | actionpack (5.2.6) lib/action_dispatch/http/request.rb:81:in `controller_class'
40
+
41
+ web_1 | actionpack (5.2.6) lib/action_dispatch/routing/route_set.rb:46:in `controller'
42
+
43
+ web_1 | actionpack (5.2.6) lib/action_dispatch/routing/route_set.rb:32:in `serve'
44
+
45
+ web_1 | actionpack (5.2.6) lib/action_dispatch/journey/router.rb:52:in `block in serve'
46
+
47
+ web_1 | actionpack (5.2.6) lib/action_dispatch/journey/router.rb:35:in `each'
48
+
49
+ web_1 | actionpack (5.2.6) lib/action_dispatch/journey/router.rb:35:in `serve'
50
+
51
+ web_1 | actionpack (5.2.6) lib/action_dispatch/routing/route_set.rb:840:in `call'
52
+
53
+ web_1 | bullet (6.1.4) lib/bullet/rack.rb:15:in `call'
54
+
21
- ```
55
+ ```
22
-
23
-
24
56
 
25
57
  ```cocnsole
26
58
 
@@ -50,6 +82,98 @@
50
82
 
51
83
  ```
52
84
 
85
+ //routes.rb
86
+
87
+
88
+
89
+ Rails.application.routes.draw do
90
+
91
+ devise_for :admins,
92
+
93
+ controllers: {
94
+
95
+ sessions: 'admins/sessions',
96
+
97
+ passwords: 'admins/passwords',
98
+
99
+ registrations: 'admins/registrations',
100
+
101
+ }
102
+
103
+ devise_for :users,
104
+
105
+ controllers: {
106
+
107
+ sessions: 'users/sessions',
108
+
109
+ passwords: 'users/passwords',
110
+
111
+ registrations: 'users/registrations',
112
+
113
+ }
114
+
115
+
116
+
117
+ devise_scope :user do
118
+
119
+ post 'users/guest_sign_in', to: 'users/sessions#guest_sign_in'
120
+
121
+ end
122
+
123
+
124
+
125
+ # 追記
126
+
127
+ namespace :api do
128
+
129
+ namespace :v1, format: 'json' do
130
+
131
+ resources :relationships, only: [:create, :destroy]
132
+
133
+ end
134
+
135
+ end
136
+
137
+
138
+
139
+ # ========= ユーザー(public)のルーティング ================
140
+
141
+ scope module: :public do
142
+
143
+ root to: 'camps#index'
144
+
145
+ get '/about' => 'homes#about'
146
+
147
+
148
+
149
+ resources :users, only: [:index, :show, :edit, :update] do
150
+
151
+ resource :relationships, only: [:create, :destroy]
152
+
153
+ resources :reservations, only: [:index, :show]
154
+
155
+ member do
156
+
157
+ get 'following'
158
+
159
+ get 'followers'
160
+
161
+ get 'favorites'
162
+
163
+ get 'post'
164
+
165
+ end
166
+
167
+ end
168
+
169
+ end
170
+
171
+ ```
172
+
173
+
174
+
175
+ ```
176
+
53
177
  //follows.html.erb
54
178
 
55
179
  <%= javascript_pack_tag 'relationship' %>

4

文章の修正

2021/09/11 08:19

投稿

Taka2401
Taka2401

スコア8

test CHANGED
File without changes
test CHANGED
@@ -12,6 +12,16 @@
12
12
 
13
13
  axiosを使い、postを実行したところ404エラーが出ました。
14
14
 
15
+ ```
16
+
17
+ //エラーログ
18
+
19
+
20
+
21
+ ```
22
+
23
+
24
+
15
25
  ```cocnsole
16
26
 
17
27
  xhr.js:184 POST http://localhost:3000/api/v1/relationships 404 (Not Found)

3

文章の修正

2021/09/11 08:14

投稿

Taka2401
Taka2401

スコア8

test CHANGED
File without changes
test CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  vueを使い非同期通信でフォロー機能を追加したいです。
4
4
 
5
- 既にフォロー機能は実装できていので、フォローボタンのみvueで非同期通信に書き換えたいです。
5
+ 既にフォロー機能は実装できていので、フォローボタンのみvueで非同期通信に書き換えたいです。
6
6
 
7
7
 
8
8
 

2

文章の修正

2021/09/11 06:28

投稿

Taka2401
Taka2401

スコア8

test CHANGED
File without changes
test CHANGED
@@ -1,8 +1,8 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
- Railsを使ったポートフォリオにvueを使い非同期通信でフォロー機能を追加したいです。
3
+ vueを使い非同期通信でフォロー機能を追加したいです。
4
-
4
+
5
- 既にフォロー機能自体は実装できていたので、フォローボタンvueで非同期通信に書き換えるとった感じです。
5
+ 既にフォロー機能は実装できていたので、フォローボタンのみvueで非同期通信に書き換えいです。
6
6
 
7
7
 
8
8
 

1

文章の修正

2021/09/11 06:26

投稿

Taka2401
Taka2401

スコア8

test CHANGED
File without changes
test CHANGED
@@ -289,3 +289,9 @@
289
289
  Ruby 2.6.3
290
290
 
291
291
  Ruby on Rails 5.2.6
292
+
293
+
294
+
295
+ 解決に繋がるヒントを頂けますと幸いです。
296
+
297
+ よろしくお願いいたします。