We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
In your Comment model, include Humanizer and add the #require_human_on method:
class Comment < ActiveRecord::Base belongs_to :post include Humanizer require_human_on :create end
In your Post model, define the relationship:
class Post < ActiveRecord::Base has_many :comments accepts_nested_attributes_for :comments end
In your posts_controller.rb file, add a new comment under the 'show' action:
def show . . . @comment = Comment.new
In your comments_controller.rb file, for the 'create' action, edit your @comment assignment, and add a @post assignment:
def create @post = Post.find(params[:post_id]) @comment = @post.comments.create(params[:comment])
Ask the question in the form (/views/posts/show.html.erb for example):
<%= form_for [@post, @comment] do |f| %> . . . <%= f.label :humanizer_answer, @comment.humanizer_question %> <%= f.text_field :humanizer_answer %> <%= f.hidden_field :humanizer_question_id %>
Thanks to foamandthunder for creating this!