Created
August 7, 2010 14:30
-
-
Save chrisconley/512862 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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 %>"><br/> | |
<input type="radio" name="flagged" value="yes" class="required"> | |
Yes, this picture is offensive | |
</input> | |
<input type="radio" name="flagged" value="no" class="required"> | |
No, this picture is okay | |
</input> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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? | |
class Post < ActiveRecord::Base | |
include Houdini::Model | |
houdini :moderates_image, | |
:price => '0.01', | |
:title => 'Please moderate image', | |
:form_template => 'app/views/houdini_templates/post.html.erb', | |
:on_postback => :process_image_moderation_answer | |
after_create :moderate_image | |
def moderate_image | |
Houdini::send_to_houdini(self) | |
end | |
def process_image_moderation_answer(answer) | |
update_attribute(:flagged => answer[:flagged] == 'yes') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment