diff --git a/app/controllers/votes_controller.rb b/app/controllers/votes_controller.rb index 733b5a7..2891042 100644 --- a/app/controllers/votes_controller.rb +++ b/app/controllers/votes_controller.rb @@ -5,7 +5,17 @@ def new end def create - Vote.create!(params[:vote]) + attributes = {:article_id => params[:vote][:article_id], :general => params[:vote][:general]} + if params[:prevent] + attributes[:effect] = "prevent" + elsif params[:cause] + attributes[:effect] = "cause" + else + attributes[:effect] = "skip" + end + if attributes[:effect] == "skip" || attributes[:general].present? + Vote.create!(attributes) + end redirect_to new_vote_path end end diff --git a/app/views/votes/new.html.erb b/app/views/votes/new.html.erb index f8547e1..e17bb96 100644 --- a/app/views/votes/new.html.erb +++ b/app/views/votes/new.html.erb @@ -7,31 +7,33 @@ <% form_for @vote do |f| %> <%= f.hidden_field :article_id %> -
Be as terse as possible, e.g. “wine”, “sun”, “HRT”
If needed, e.g. “red wine”
+ <%= f.submit "Causes cancer", :name => "cause" %> + <%= f.submit "Prevents cancer", :name => "prevent" %> + <%= f.submit "Skip this", :name => "skip" %>