teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

コードの追加

2021/10/28 07:37

投稿

uruman
uruman

スコア12

title CHANGED
File without changes
body CHANGED
@@ -3,8 +3,20 @@
3
3
  Railsでいいね機能を実装しようとしたところ、エラー文がでてしまいます。
4
4
 
5
5
  ### 発生している問題・エラーメッセージ
6
+ ```routes
7
+ Rails.application.routes.draw do
8
+ devise_for :users
9
+ root to: 'homes#top'
10
+ get 'home/about' => 'homes#index'
6
11
 
12
+ resources :books,only:[:new,:create,:index,:show,:destroy,:edit,:update]do
13
+ resource :favorites,only:[:create,:destroy]
14
+ end
15
+ resources :users,only:[:show,:new,:index,:edit,:create,:update]
16
+ end
17
+
7
18
  ```
19
+ ```
8
20
  ActionView::MissingTemplate in Books#show
9
21
  Showing /home/ec2-user/environment/bookers2_rails/app/views/books/show.html.erb where line #23 raised:
10
22
 

1

コードの追加

2021/10/28 07:37

投稿

uruman
uruman

スコア12

title CHANGED
File without changes
body CHANGED
@@ -21,6 +21,13 @@
21
21
  ```
22
22
 
23
23
  ### 該当のソースコード
24
+ ```
25
+ <% if @book.favorited_by?(current_user)%>
26
+ <%=link_to book.favorites.count,favorites_path(book), method: :delete class: "fas fa-heart heart_red" %>
27
+ <%else%>
28
+ <%= link_to book.favorites.count,favorites_path(book), method: :post class: "fas fa-heart heart_bule" %>
29
+ <%end%>
30
+ ```
24
31
 
25
32
  ```showhtml
26
33
  ..省略..