Permalink
Browse files

Allow visitors to tell me about bogus results.

  • Loading branch information...
1 parent 5bde8e8 commit 05513a49625f8fdd1ea5377073f0aabf3347c664 @threedaymonk committed Jul 19, 2009
@@ -0,0 +1,12 @@
+class CorrectionsController < ApplicationController
+ def new
+ @backlink = request.env["HTTP_REFERER"] || results_path
+ @tagging = NormalizedTagging.find_by_article_id_and_normalized_term_id_and_good(params[:article_id], params[:normalized_term_id], params[:good]=="1")
+ end
+
+ def create
+ NormalizedTagging.increment_counter(:votes_against, params[:id])
+ redirect_to params[:backlink]
+ end
+end
+
@@ -0,0 +1,32 @@
+<p>If this entry is incorrect, i.e. it doesn't refer to the item mentioned, or the conclusion is invalid, please submit a report. The item will be removed from the results in due course.</p>
+<% form_tag corrections_path(:id => @tagging.id) do %>
+ <table>
+ <tr>
+ <th>Thing</th>
+ <td><%= h(@tagging.normalized_term.value) %></td>
+ </tr>
+ <tr>
+ <th>Effect</th>
+ <td><%= @tagging.good? ? "Prevents cancer" : "Causes cancer" %></td>
+ </tr>
+ <tr>
+ <th>Headline</th>
+ <td><%= h(@tagging.article.title) %></td>
+ </tr>
+ <tr>
+ <th>Summary</th>
+ <td><%= h(@tagging.article.summary) %></td>
+ </tr>
+ <tr>
+ <th>URL</th>
+ <td><%= link_to(@tagging.article.link, @tagging.article.link, :target => "_blank") %></td>
+ </tr>
+ </table>
+
+ <%= hidden_field_tag "backlink", @backlink %>
+
+ <p>
+ <input type="submit" value="Yes, this is incorrect" />
+ <%= link_to "No, take me back", :back %>
+ </p>
+<% end %>
@@ -1,4 +1,8 @@
+<p>If any of these results seems incorrect, please use the link next to the article in question to report it.</p>
+
<% @terms.each do |term| %>
+ <% next unless term.articles.any? %>
+
<h2 class="termHeading <%= term.effect %>">
<em><%= h(term.value) %></em>
<% case term.effect; when :cause %>
@@ -17,6 +21,9 @@
<% term.causes_articles.each do |article| %>
<li>
<%= link_to article.title, article.link %>
+ <span class="debug">[<%=
+ link_to("Incorrect?", new_correction_path(:article_id => article.id, :normalized_term_id => term.id, :good => 0))
+ %>]</span>
</li>
<% end %>
</ul>
@@ -27,6 +34,9 @@
<% term.prevents_articles.each do |article| %>
<li>
<%= link_to article.title, article.link %>
+ <span class="debug">[<%=
+ link_to("Incorrect?", new_correction_path(:article_id => article.id, :normalized_term_id => term.id, :good => 1))
+ %>]</span>
</li>
<% end %>
</ul>
View
@@ -1,7 +1,8 @@
ActionController::Routing::Routes.draw do |map|
- map.homepage "/", :controller => "home", :action => "index"
- map.stats "/stats", :controller => "stats", :action => "index"
- map.results "/results", :controller => "results", :action => "index"
- map.done "/done", :controller => "votes", :action => "done"
+ map.homepage "/", :controller => "home", :action => "index"
+ map.stats "/stats", :controller => "stats", :action => "index"
+ map.results "/results", :controller => "results", :action => "index"
+ map.done "/done", :controller => "votes", :action => "done"
map.resources :votes
+ map.resources :corrections
end
@@ -0,0 +1,9 @@
+class VoteAgainstNormalizedTaggings < ActiveRecord::Migration
+ def self.up
+ add_column "normalized_taggings", "votes_against", :integer, :default => 0
+ end
+
+ def self.down
+ remove_column "normalized_taggings", "votes_against"
+ end
+end
View
@@ -9,7 +9,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20090714204353) do
+ActiveRecord::Schema.define(:version => 20090719224733) do
create_table "articles", :force => true do |t|
t.text "link"
@@ -24,6 +24,7 @@
t.integer "normalized_term_id"
t.integer "article_id"
t.boolean "good"
+ t.integer "votes_against", :default => 0
end
create_table "normalized_terms", :force => true do |t|
@@ -62,3 +62,8 @@ ul.cause {
ul.prevent {
color: #0b0;
}
+span.debug,
+span.debug a {
+ font-size: 12px;
+ color: #888;
+}

0 comments on commit 05513a4

Please sign in to comment.