Files
growstuff/app/views/posts/_likes.html.haml
Brenda Wallace c0b2a8431b Reinstate likes
2019-06-14 11:01:16 +12:00

19 lines
602 B
Plaintext

- if member_signed_in?
- if !post.members.include? current_member
- if can?(:new, Like)
= link_to 'Like', likes_path(post_id: post.id, format: :json),
method: :post, remote: true, class: 'post-like btn'
- else
- like = post.likes.find_by(member: current_member)
- if like && can?(:destroy, like)
= link_to 'Unlike', like_path(id: like.id, format: :json),
method: :delete, remote: true, class: 'post-like btn'
%span.badge.badge-info
.like-count
- unless post.likes.empty?
= like_icon
= pluralize(post.likes.count, "like")