diff --git a/README.rdoc b/README.rdoc index 1958f62..f5e346e 100644 --- a/README.rdoc +++ b/README.rdoc @@ -119,11 +119,14 @@ It is strongly recommended to enable caching. You can see the three paramters wh <% if request.post? %>
<%= valid_captcha?(params[:captcha]) ? 'valid' : 'invalid' %> captcha
<% end %> -<%= captcha_tag %>
+<%= captcha_tag( url , {}) %>
<%= text_field_tag :captcha %>
<%= submit_tag 'Validate' %>
<% end %> +== captcha_tag裡的url 要將從被引用的專案使用 +原因: 否則 environment/production.rb 設定 config.action_controller.asset_host 會讓 captcha_tag 帶入asset_host 而無法正常顯示 + == Example app You find an example app under: http://github.com/phatworx/easy_captcha_example diff --git a/lib/easy_captcha/view_helpers.rb b/lib/easy_captcha/view_helpers.rb index 1820eee..9f0fe1e 100644 --- a/lib/easy_captcha/view_helpers.rb +++ b/lib/easy_captcha/view_helpers.rb @@ -2,10 +2,10 @@ module EasyCaptcha # helper class for ActionView module ViewHelpers # generate an image_tag for captcha image - def captcha_tag(*args) + def captcha_tag(captcha_image_path = captcha_path(:i => Time.now.to_i), custom_options = {}) options = { :alt => 'captcha', :width => EasyCaptcha.image_width, :height => EasyCaptcha.image_height } - options.merge! args.extract_options! - image_tag(captcha_path(:i => Time.now.to_i), options) + options.merge! custom_options + image_tag(captcha_image_path , options) end end end