Skip to content

Commit

Permalink
Made vote form easier to use. One text box and three buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
threedaymonk committed Jul 12, 2009
1 parent e0cdab6 commit 531f319
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
12 changes: 11 additions & 1 deletion app/controllers/votes_controller.rb
Expand Up @@ -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
36 changes: 19 additions & 17 deletions app/views/votes/new.html.erb
Expand Up @@ -7,31 +7,33 @@
<% form_for @vote do |f| %>
<%= 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.