Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Twoots controller:
- def comment_like
- @twoot = Twoot.find(params[:id])
- @comment = NO IDEA WHAT TO PUT THERE
- current_user.favorite(@comment)
- redirect_to twoot_path(@twoot)
- end
- def comment_unlike
- @twoot = Twoot.find(params[:id])
- @comment = SAME, NO IDEA
- current_user.remove_favorite(@comment)
- redirect_to twoot_path(@twoot)
- end
- Views:
- <% @comments.each do |comment| %>
- ...
- <% if user_signed_in? %>
- <% if comment.favorited_by?(current_user) %>
- <%= button_to 'Unlike', {action: "comment_unlike" }, { class: "btn waves-effect hoverable red lighten-2" } %>
- <% else %>
- <%= button_to 'Like', {action: "comment_like" }, { class: "btn waves-effect hoverable red lighten-2" } %>
- <% end %>
- <% end %>
- <% end %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement