Associate first organizer to vote
This commit is contained in:
parent
aefc722c9d
commit
3783b5ffd0
1 changed files with 10 additions and 7 deletions
17
vote.rb
17
vote.rb
|
|
@ -93,6 +93,16 @@ get '/votes/new' do
|
|||
erb :votes_new
|
||||
end
|
||||
|
||||
post '/votes' do
|
||||
redirect '/login' unless current_user
|
||||
@vote = Vote.create(secure_id: SecureRandom.hex(8),
|
||||
title: params[:title],
|
||||
description: params[:description],
|
||||
state: "draft")
|
||||
@vote.users << current_user
|
||||
redirect '/votes/' + @vote.secure_id
|
||||
end
|
||||
|
||||
get '/votes/:id' do
|
||||
redirect '/login' unless current_user
|
||||
@vote = Vote.find_by(secure_id: params[:id])
|
||||
|
|
@ -120,13 +130,6 @@ post '/votes/:id/edit' do
|
|||
erb :votes_edit
|
||||
end
|
||||
|
||||
post '/votes' do
|
||||
@vote = Vote.create(secure_id: SecureRandom.hex(8),
|
||||
title: params[:title],
|
||||
description: params[:description])
|
||||
redirect '/votes/' + @vote.secure_id
|
||||
end
|
||||
|
||||
post '/votes/:id/candidates' do
|
||||
redirect '/login' unless current_user
|
||||
@vote = Vote.find_by(secure_id: params[:id])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue