diff --git a/vote.rb b/vote.rb index 994e283..0c53d72 100644 --- a/vote.rb +++ b/vote.rb @@ -173,6 +173,7 @@ post '/votes/:id/draft' do redirect '/login' unless current_user @vote = Vote.find_by(secure_id: params[:id]) redirect '/votes/' + @vote.secure_id unless @vote.state == "open" and @vote.users.exists?(current_user.id) + @vote.ratings.each {|r| r.destroy} @vote.state = "draft" @vote.save redirect '/votes/' + @vote.secure_id