Permalink
Browse files

Made vote form easier to use. One text box and three buttons.

  • Loading branch information...
1 parent e0cdab6 commit 531f3192ea992714e421edaa14d93fba4b56d33a @threedaymonk committed Jul 12, 2009
Showing with 30 additions and 18 deletions.
  1. +11 −1 app/controllers/votes_controller.rb
  2. +19 −17 app/views/votes/new.html.erb
@@ -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
@@ -8,30 +8,32 @@
<%= f.hidden_field :article_id %>
<div class="row">
- <%= f.label :effect, "What is the effect?" %>
- <%= f.select :effect, ["No effect", "Increased risk of cancer", "Reduced risk of cancer"] %>
- </div>
-
- <div class="row">
<%= f.label :general, "What kind of a thing is it?" %>
<%= f.text_field :general %>
- <p>Be as terse as possible, e.g. “wine”, “sun”, “HRT”</p>
</div>
+ <ul>
+ <li>
+ Be <strong>as terse as possible</strong>, e.g. “wine”, “sun”, “HRT”.
+ </li>
+ <li>
+ If the article refers to more than one thing, <strong>separate them with commas</strong>, e.g.
+ “fruit, vegetables”.
+ </li>
+ <li>
+ <strong>Capital letters don’t matter</strong>.
+ </li>
+ <li>
+ If the article isn’t about something that causes or prevents cancer, or if it’s ambiguous, <strong>skip it</strong>.
+ </li>
+ </ul>
+
<div class="row">
- <%= f.label :specific, "Specific details" %>
- <%= f.text_field :specific %>
- <p>If needed, e.g. “red wine”</p>
+ <%= f.submit "Causes cancer", :name => "cause" %>
+ <%= f.submit "Prevents cancer", :name => "prevent" %>
+ <%= f.submit "Skip this", :name => "skip" %>
</div>
- <%= f.submit "Classify" %>
<% end %>
</div>
-<div id="skip">
- <% form_for @vote do |f| %>
- <%= f.hidden_field :article_id %>
- <%= f.hidden_field :effect, :value => "skip" %>
- <%= f.submit "Irrelevant" %>
- <% end %>
-</div>

0 comments on commit 531f319

Please sign in to comment.