Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ It is strongly recommended to enable caching. You can see the three paramters wh
<% if request.post? %>
<p><%= valid_captcha?(params[:captcha]) ? 'valid' : 'invalid' %> captcha</p>
<% end %>
<p><%= captcha_tag %></p>
<p><%= captcha_tag( url , {}) %> </p>
<p><%= text_field_tag :captcha %></p>
<p><%= submit_tag 'Validate' %></p>
<% 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

Expand Down
6 changes: 3 additions & 3 deletions lib/easy_captcha/view_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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