Skip to content

Commit

Permalink
Allow custom mount path
Browse files Browse the repository at this point in the history
with RuCaptcha.config.mount_path
  • Loading branch information
Gao-Jun authored and huacnlee committed Oct 16, 2023
1 parent f7ce802 commit 2d64a0b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ RuCaptcha.configure do

# Set the image format, default: png, allows: [jpeg, png, webp]
# self.format = 'png'

# Custom mount path, default: '/rucaptcha'
# self.mount_path = '/rucaptcha'
end
```

Expand Down
1 change: 1 addition & 0 deletions lib/rucaptcha.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def config
@config.line = true
@config.noise = true
@config.format = "png"
@config.mount_path = "/rucaptcha"

@config.cache_store = if Rails.application
Rails.application.config.cache_store
Expand Down
2 changes: 2 additions & 0 deletions lib/rucaptcha/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ class Configuration
attr_accessor :format
# skip_cache_store_check, default: false
attr_accessor :skip_cache_store_check
# custom rucaptcha mount path, default: '/rucaptcha'
attr_accessor :mount_path
end
end
2 changes: 1 addition & 1 deletion lib/rucaptcha/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Engine < ::Rails::Engine
# https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/action_dispatch/routing/route_set.rb#L268
# `app.routes.prepend` start from Rails 3.2 - 5.0
app.routes.prepend do
mount RuCaptcha::Engine => "/rucaptcha"
mount RuCaptcha::Engine => RuCaptcha.config.mount_path
end

RuCaptcha.check_cache_store! unless RuCaptcha.config.skip_cache_store_check
Expand Down

0 comments on commit 2d64a0b

Please sign in to comment.