Skip to content

Instantly share code, notes, and snippets.

@juanfgs
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanfgs/47428af01015c646075e to your computer and use it in GitHub Desktop.
Save juanfgs/47428af01015c646075e to your computer and use it in GitHub Desktop.
issues with recaptcha
class CommentsController < ApplicationController
def create
@post = Post.find(params[:comment][:post_id])
@comment = Comment.new
@comment.name = params[:comment][:name]
@comment.comment = params[:comment][:comment]
if verify_recaptcha(:model => @comment) && @comment.valid?
@post.comments << @comment
redirect_to :back, flash: {message: "Thank you for your comment "}
else
@comment.errors.each do |attribute, error|
flash[attribute] = error
end
redirect_to :back
end
end
end
end
end
Recaptcha.configure do |config|
config.public_key = '6LeI7wETAAAAALTGxu5UeNAaZhTHem7Ar9g49dXG'
config.private_key = '6LeI7wETAAAAANW3wF3k3AOcxat6uxhGJHghWKf6'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment