Skip to content

Commit

Permalink
Merge branch 'introkun/master'
Browse files Browse the repository at this point in the history
Conflicts:
	lib/recaptcha.rb
  • Loading branch information
Jason L Perry committed Sep 12, 2009
2 parents 113e3fb + 6fe11d8 commit 0deb6bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.rdoc
Expand Up @@ -32,8 +32,13 @@ isn't this a model validation? Because that violates MVC. Use can use it like th
like. Passing in the ActiveRecord object is optional, if you do--and the captcha fails to verify--an
error will be added to the object for you to use.

Some of the options available:

<tt>:model</tt>:: Model to set errors
<tt>:message</tt>:: Custom error message

respond_to do |format|
if verify_recaptcha(:model => @post) && @post.save
if verify_recaptcha(:model => @post, :message => 'Oh! It's error with ReCaptcha!') && @post.save
# ...
else
# ...
Expand Down
4 changes: 2 additions & 2 deletions lib/recaptcha.rb
Expand Up @@ -68,9 +68,9 @@ def verify_recaptcha(options = {})
if model
model.valid?
if Rails::VERSION::MAJOR == 2 and Rails::VERSION::MINOR >= 2
model.errors.add :base, I18n.translate("#{model.class.name.underscore}.captcha", :scope => %w(errors models), :default => "Captcha response is incorrect, please try again.")
model.errors.add :base, I18n.translate("#{model.class.name.underscore}.captcha", :scope => %w(errors models), :default => (options[:message] || "Captcha response is incorrect, please try again."))
else
model.errors.add :base, "Captcha response is incorrect, please try again."
model.errors.add :base, options[:message] || "Captcha response is incorrect, please try again."
end
end
return false
Expand Down

0 comments on commit 0deb6bb

Please sign in to comment.