Skip to content

Instantly share code, notes, and snippets.

@nicholaides
Forked from chrisconley/post.html.erb
Created August 10, 2010 13:14
Show Gist options
  • Save nicholaides/517242 to your computer and use it in GitHub Desktop.
Save nicholaides/517242 to your computer and use it in GitHub Desktop.
<!-- app/views/houdini_templates/post.html.erb -->
<h2>Review the image for offensiveness</h2>
<h3>Instructions</h3>
<p>Please review the image below.</p>
<img src="<%= post.image_url %>">
<p>
<input type="radio" name="flagged" value="yes"/>
Yes, this picture is offensive
</p>
<p>
<input type="radio" name="flagged" value="no"/>
No, this picture is okay
</p>
# app/models/post.rb
# Additional notes for me:
# * change :on_submit to :after_submit
# * send success, errors to :after_submit instead of response, body
# * Use :title as :identifier?
# Mike's notes
# removed title -> I think this should be taken from "houdini :moderates_image"
# :on_postback could be :on_complete or :on_task_completion
class Post < ActiveRecord::Base
include Houdini::Model
houdini :moderates_image,
:price => '0.01',
:form_template => 'app/views/houdini_templates/post.html.erb',
:on_postback => :process_image_moderation_answer
after_create :send_to_houdini
def process_image_moderation_answer(params)
update_attributes(:flagged => (params[:flagged] == 'yes'))
end
def send_to_houdini
Houdini.send_to_houdini(self)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment