質問編集履歴
3
ルーティングを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -202,6 +202,76 @@
|
|
202
202
|
|
203
203
|
|
204
204
|
|
205
|
+
#### (追記)ルーティング
|
206
|
+
|
207
|
+
```ruby
|
208
|
+
|
209
|
+
Rails.application.routes.draw do
|
210
|
+
|
211
|
+
devise_for :customer_users, controllers: {
|
212
|
+
|
213
|
+
sessions: 'customer_users/sessions',
|
214
|
+
|
215
|
+
passwords: 'customer_users/passwords',
|
216
|
+
|
217
|
+
registrations: 'customer_users/registrations'
|
218
|
+
|
219
|
+
}
|
220
|
+
|
221
|
+
devise_scope :customer_user do
|
222
|
+
|
223
|
+
post 'customer_users/guest_sign_in', to: 'customer_users/sessions#guest_sign_in'
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
devise_for :owner_users, controllers: {
|
230
|
+
|
231
|
+
sessions: 'owner_users/sessions',
|
232
|
+
|
233
|
+
passwords: 'owner_users/passwords',
|
234
|
+
|
235
|
+
registrations: 'owner_users/registrations'
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
root to: 'stores#index'
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
resources :stores, except: [:index] do
|
244
|
+
|
245
|
+
resources :reviews, only: [:index, :create]
|
246
|
+
|
247
|
+
resources :bookmarks, only: [:create, :destroy]
|
248
|
+
|
249
|
+
collection do
|
250
|
+
|
251
|
+
get 'keyword_search'
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
end
|
256
|
+
|
257
|
+
resources :tags do
|
258
|
+
|
259
|
+
get 'tag_search', to: 'stores#tag_search'
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
resources :customer_users, only: [:index, :show]
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
```
|
272
|
+
|
273
|
+
|
274
|
+
|
205
275
|
### 試したこと
|
206
276
|
|
207
277
|
500 (Internal Server Error)が出ているため、サーバー側の問題かと思い
|
2
ターミナル上のエラーメッセージ追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,6 +30,30 @@
|
|
30
30
|
|
31
31
|
```
|
32
32
|
|
33
|
+
(追記)ターミナル上のエラーメッセージ
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
Completed 500 Internal Server Error in 104ms (ActiveRecord: 15.6ms | Allocations: 17849)
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
ActionView::Template::Error (No route matches {:action=>"destroy", :controller=>"bookmarks", :store_id=>#<Store id: 7, name: 〜ブックマークする投稿内容のデータなので省略〜, owner_user_id: 1, created_at: "2021-03-25 07:01:47", updated_at: "2021-03-25 07:01:48">}, missing required keys: [:id]):
|
42
|
+
|
43
|
+
1: <%= link_to store_bookmark_path(@store), method: :delete, remote: true do %>
|
44
|
+
|
45
|
+
2: <i class="fas fa-bookmark icon"></i>
|
46
|
+
|
47
|
+
3: <% end %>
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
app/views/bookmarks/_unbkm.html.erb:1
|
52
|
+
|
53
|
+
app/views/bookmarks/create.js.erb:1
|
54
|
+
|
55
|
+
```
|
56
|
+
|
33
57
|
画面をリロードすると、アイコンに色がつきブックマークができている。
|
34
58
|
|
35
59
|
また、ブックマークを解除する処理については、非同期で問題なく処理できている。
|
1
ビュー修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -98,6 +98,28 @@
|
|
98
98
|
|
99
99
|
###### ビュー
|
100
100
|
|
101
|
+
|
102
|
+
|
103
|
+
```
|
104
|
+
|
105
|
+
~中略~
|
106
|
+
|
107
|
+
<% if customer_user_signed_in? %>
|
108
|
+
|
109
|
+
<div id="bookmark-icon" class="bookmark-icon">
|
110
|
+
|
111
|
+
<%= render 'bookmarks/bookmark', store: @store %>
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
<% end %>
|
116
|
+
|
117
|
+
~中略~
|
118
|
+
|
119
|
+
```
|
120
|
+
|
121
|
+
_bookmark.html.erb
|
122
|
+
|
101
123
|
```html
|
102
124
|
|
103
125
|
<% if !Bookmark.exists?(customer_user_id: current_customer_user.id, store_id: store.id) %>
|