SHARE
TWEET

Untitled

a guest Apr 13th, 2019 128 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Twoots controller:
  2.  
  3.   def comment_like
  4.     @twoot = Twoot.find(params[:id])
  5.     @comment = NO IDEA WHAT TO PUT THERE
  6.     current_user.favorite(@comment)
  7.     redirect_to twoot_path(@twoot)
  8.   end
  9.  
  10.   def comment_unlike
  11.     @twoot = Twoot.find(params[:id])
  12.     @comment = SAME, NO IDEA
  13.     current_user.remove_favorite(@comment)
  14.     redirect_to twoot_path(@twoot)
  15.   end
  16.  
  17.  
  18. Views:
  19. <% @comments.each do |comment| %>
  20. ...
  21. <% if user_signed_in? %>
  22.   <% if comment.favorited_by?(current_user) %>
  23.     <%= button_to 'Unlike', {action: "comment_unlike" }, { class: "btn waves-effect hoverable red lighten-2" } %>
  24.    <% else %>
  25.     <%= button_to 'Like', {action: "comment_like" }, { class: "btn waves-effect hoverable red lighten-2" } %>
  26. <% end %>
  27. <% end %>
  28. <% end %>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top