I'd like to implement a like function for posting a Twitter clone, but I got an error saying "There is no such method" in the self part of the user model below, but make sure that current_user is included in self. I'm going to

#user model
class User</pre>
<pre><code>#favorite controller
class FavoritesController</pre>
<pre><code>`` ```
Call it in a different file as a partial.
<% if current_user.already_favorite? (Micropost)%>
<% = link_to'Unlike', favorite_path (micropost), method:: delete%>
<% else%>
<% = link_to'Like', favorites_path, method:: post%>
<% end%>
  • Answer # 1

    user = User.find (params [: micropostw_id])
    user = User.find (params [: micropost_id])
    What happens if I fix it to? (wIs a typo? )

    Also, regardless of the city that deals with itparamsIt seems better to check if the value contained is the expected value.

Related articles