Skip to content

Commit

Permalink
Redirect after voting even if no referer is set
Browse files Browse the repository at this point in the history
  • Loading branch information
drusepth committed Apr 28, 2017
1 parent e731074 commit be30adb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/controllers/voting_controller.rb
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

0 comments on commit be30adb

Please sign in to comment.