-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect after voting even if no referer is set
- Loading branch information
Showing
1 changed file
with
3 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
class VotingController < ApplicationController | ||
def vote | ||
if !user_signed_in? || current_user.votes.where(votable_id: nil).count < 1 | ||
redirect_to :back | ||
redirect_to community_voting_path | ||
return | ||
end | ||
|
||
votable = Votable.find(params[:id]) | ||
if votable.nil? | ||
redirect_to :back | ||
redirect_to community_voting_path | ||
return | ||
end | ||
|
||
vote_to_cast = current_user.votes.where(votable_id: nil).first | ||
vote_to_cast.update votable_id: votable.id | ||
redirect_to :back, notice: "You voted for #{votable.name} successfully!" | ||
redirect_to community_voting_path, notice: "You voted for #{votable.name} successfully!" | ||
end | ||
end |