Skip to content

Commit

Permalink
added spam and ham scopes for future use
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Craig committed Jan 28, 2011
1 parent f780878 commit c5ee04f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion app/models/noodall/form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ class Form

MANDATORY_FIELDS = ['Name','Email']
many :fields, :class => Noodall::Field
many :responses, :class => Noodall::FormResponse
many :responses, :class => Noodall::FormResponse do
def ham
self.select {|r| r.spaminess < (self.class.defensio_config['spam_threshold'] || 0.75)}
end
def spam
self.select {|r| r.spaminess >= (self.class.defensio_config['spam_threshold'] || 0.75)}
end
end

before_save :create_mandatory_fields!

Expand Down
2 changes: 1 addition & 1 deletion app/views/noodall/admin/forms/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<td class="edit"><%= link_to h(form.title), noodall_admin_form_path(form), :class => 'edit', :title => "Edit #{form.title}" %></td>
<td><%= form.email %></td>
<td class="child">
<%= link_to pluralize(form.responses.size, "Response"), noodall_admin_form_form_responses_path(form), :title => "View responses for #{h(form.title)}", :class => 'child-no' %> <%= link_to 'Download Responses', noodall_admin_form_form_responses_path(form, :csv), :class => 'download', :title => 'Download the responses for this form in CSV format' %></td>
<%= link_to pluralize(form.responses.ham.size, "Response"), noodall_admin_form_form_responses_path(form), :title => "View responses for #{h(form.title)}", :class => 'child-no' %> <%= link_to 'Download Responses', noodall_admin_form_form_responses_path(form, :csv), :class => 'download', :title => 'Download the responses for this form in CSV format' %></td>
<td><%= link_to 'Delete', noodall_admin_form_path(form), :confirm => 'Are you sure?', :method => :delete, :class => 'delete', :title => 'Delete this form' %></td>
</tr>
<% end %>
Expand Down

0 comments on commit c5ee04f

Please sign in to comment.