-2

Friends i have controller with the name of shops and i have did likes and unlike option against a post.Now i want to make a third option for dislike.The purpose is that i want to show down voting.I am using rails 4 version and here below my code.Kindly help me as i dont know how to figure out my problem.

  • 1
    Could you explain some more about what is going wrong for you? – Neil Slater May 01 '14 at 07:37
  • i dont know how to write function in shops controller for dislike. – user3571427 May 01 '14 at 07:57
  • I have a status field in shoplikes table. I want to update this status filed 1 when like and -1 for dislike and by default it is 0. Now i want that there should be single field which should be updated according to user like, dislike .As in my code i am just counting likes but i also want to count dislike. – user3571427 May 01 '14 at 08:00

1 Answers1

2

I think it would be better to start from scratch with a common Voting model. In your code above you have written only a controller and a view, but you need also a model.

Basically you need a Vote model and a controller with like, dislike and get_vote methods. And don't forget to join the votes, users and voteable items.

For a hint how you could implement this, you can also see here: "Like", "Dislike" plugin for rails

Community
  • 1
  • 1
dwettstein
  • 667
  • 1
  • 7
  • 17