Delete ratings when change a vote back to draft
This commit is contained in:
parent
4462159b93
commit
9c2adb1072
1 changed files with 1 additions and 0 deletions
1
vote.rb
1
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue