They can use the remove vote button or select the same option again for single choice polls.
Do we need to
push it if it’s
Should probably use the
DELETE verb and a different route on the server to handle the removal of a vote
Why couldn’t they remove their vote on multiple choices polls?
I think we still need this since we should be using a different route for the vote removal
This handles the case when a user clicks again on the option. I implemented this just for single choice polls because it is a bad user experience for multiple choice polls.
I see. Nice.
How does the button look like? Would it be better to make it red?
This pull request has been mentioned on Discourse Meta. There might be relevant details there:
I’m personally not a huge fan of extending the
DiscoursePoll::Poll.vote method to be able to remove vote because the original intend of the method is to cast a vote. A new method like
DiscoursePoll::Poll.remove_vote would make it much clearer IMO.
This is not related to your change but I wished we had use a custom error class instead. This is rescuing all errors whether they are related to poll vote or not.
@nbianca I really like the refactor that you did here. Things are properly organised and alot easier to follow.
Love that you’ve made a method for each operations
I would have put the
current_user as the 1st parameter but that’s nitpicking.
Since you’re not using
post anywhere else, there’s no point in loading it using
find_by. Maybe just use
Why was this removed?
It was unused.