Created
May 18, 2010 09:21
-
-
Save skojin/404809 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
# recaptcha gem fail when load as ajax, do this in right way | |
module RecaptchaHelper | |
def ajax_recaptcha_script_url(options = {}) | |
uri = options[:ssl] ? Recaptcha::RECAPTCHA_API_SECURE_SERVER : Recaptcha::RECAPTCHA_API_SERVER | |
"#{uri}/js/recaptcha_ajax.js" | |
end | |
# Your public API can be specified in the +options+ hash or preferably | |
# the environment variable +RECAPTCHA_PUBLIC_KEY+. | |
def ajax_recaptcha_tags(options = {}) | |
# Default options | |
key = options[:public_key] ||= ENV['RECAPTCHA_PUBLIC_KEY'] | |
raise Recaptcha::RecaptchaError, "No public key specified." unless key | |
display_options_json = (options[:display] || {}).to_json | |
html = "" | |
html << %{<div id="dynamic_recaptcha"></div>} | |
html << %{<script type="text/javascript">\n} | |
html << %{ Recaptcha.create('#{key}', 'dynamic_recaptcha', #{display_options_json});\n} | |
html << %{</script>\n} | |
return html | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment