0

I have implemented a like dislike feature in my application now I would like to make it possible for someone to change his/her mind. Currently, I have

validates_uniqueness_of :user, scope: :status

in my like model, from my understanding that means once someone has liked or disliked a post they cannot change their mind.

I have already added a dislike action to my status controller, but I can't get passed that validation even when I read the apidock documentation. Is there a way to go around that validation constraint?

Ben
  • 139
  • 1
  • 2
  • 10
  • you should add how you are marking something as liked and how you plan to mark something as disliked. Does it mean that there are 3 states, liked, disliked and no status? I would've also suggested Meier's answer but it seems like it's not as simple as that based on your implementation. – jvnill Jun 07 '15 at 11:53
  • Which I have come to realize but I think a simpler way will be to use the method discussed at [link](http://stackoverflow.com/questions/24221367/like-button-ajax-in-ruby-on-rails) – Ben Jun 07 '15 at 12:48

1 Answers1

0

When the user does not like something anymore, you can just delete the like-object.

Meier
  • 3,858
  • 1
  • 17
  • 46
  • Something like "if user has already liked a status then clicks dislike, delete like and add dislike " – Ben Jun 07 '15 at 09:17