Comments (5)
Do you use Model (attribute validation in the model) style or Controller (with before_filter) style implementation?
- Model: you need to keep attribute (
:subtitle
for example) to the attributes hash, so you need to permit the attribute (example:params.require(:topic).permit(:subtitle)
). - Controller: you need to call
before_filter :check_invisible_captcha
before any otherbefore_filter
in order to perform theinvisible_captcha
validation with expected parameters and values, so you just need to not change the params hash.
If you can provide a little more information of your implementation case or a sample code, I can probably be more specific.
Anyway, documentation needs an update about strong_parameters
👍
from invisible_captcha.
Sorry, I used the controller style. In your model style above, I take it 'subtitle' is the honeypot attribute? it seems like that would be better for me anyway, if I can set my own attr name via model style .
from invisible_captcha.
Yes, :subtitle
is the honeypot. For example (class Topic):
Model style:
In your form:
<%= form_for(@topic) do |f| %>
<%= f.invisible_captcha :subtitle %>
<% end %>
In your model:
class Topic < ActiveRecord::Base
attr_accessor :subtitle # virtual attribute, honeypot
validates :subtitle, :invisible_captcha => true
end
In your contoller permit the param: params.require(:topic).permit(:subtitle)
.
Controller style:
In your form:
<%= form_for(@topic) do |f| %>
<%= invisible_captcha %>
<% end %>
In your controller add:
before_filter :check_invisible_captcha
Controller style (resource oriented):
In your form:
<%= form_for(@topic) do |f| %>
<%= f.invisible_captcha :subtitle %>
<% end %>
In your controller:
def create
if invisible_captcha?(:topic, :subtitle)
head 200 # or redirect_to new_topic_path
else
# regular workflow
end
end
I think these examples enhance the current documentation. I'll do an update soon.
from invisible_captcha.
They really do! Thanks for picking this project up!
Jarrett Green
CHIEF PRODUCT DEVELOPMENT OFFICER
tel. 316-927-2668
www. balancedcomp.com
tw. @balancedcomp
BalancedComp
Accurate. Tailored. Balanced.
On Wed, Nov 20, 2013 at 5:44 PM, Marc Anguera Insa <[email protected]
wrote:
Yes, :subtitle is the honeypot. For example (class Topic):
Model style:
In your form:
<%= form_for(@topic) do |f| %>
<%= f.invisible_captcha :subtitle %>
<% end %>In your model:
class Activity < ActiveRecord::Base
attr_accessor :subtitle # virtual attribute, honeypot
validates :subtitle, :invisible_captcha => true
endIn your contoller permit the param:
params.require(:topic).permit(:subtitle).Controller style:
In your form:
<%= form_for(@topic) do |f| %>
<%= invisible_captcha %>
<% end %>In your controller add:
before_filter :check_invisible_captchaController style (resource oriented):
In your form:
<%= form_for(@topic) do |f| %>
<%= f.invisible_captcha :subtitle %>
<% end %>In your controller:
def create
if invisible_captcha?(:topic, :subtitle)
head 200 # or redirect_to new_topic_path
else
# regular workflow
end
endI think these examples enhance the current documentation. I'll do an
update soon.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/1#issuecomment-28944551
.
from invisible_captcha.
You're welcome @balancedcomp. Stars are appreciated 😃
I'll keep issue open until I can update documentation.
from invisible_captcha.
Related Issues (20)
- Adding recaptcha to handle the chrome auto fill bug HOT 5
- Undefined method remote_ip HOT 1
- Tips when used together with Sorcery gem. HOT 1
- By using I18n.with_locale(..) in app_controller action is not called HOT 3
- IP spinner validation when forms are added with JS HOT 1
- Timestamp validation when forms are submitted with JS HOT 1
- Option with dynamic honeypot (collection of default honeypots) does not use scope HOT 1
- Submit form on multi tabs HOT 3
- Potential spam detected for IP 127.0.0.1. Invisible Captcha spinner value mismatch HOT 2
- Markup not valid when run through HTML validator HOT 6
- Each spinner should have a unique HTML ID
- `#honeypot_spam?` does not use `:scope` option if `:honeypot` option is not also set. HOT 1
- InvisibleCaptcha::ControllerExt honeypot attribute ActiveSupport::Notifications dispatches an `invisible_captcha.spam_detected` event test is failing now HOT 10
- Edge case with scope changes in 2.1.0
- It's difficult to write tests HOT 3
- [Invisible Captcha] Potential spam detected for IP 127.0.0.1. Timestamp not found in session. HOT 13
- Captcha field visible in Rails 7.1 HOT 5
- Compare params[honeypot] with blank string instead of .present? HOT 3
- Chrome sometimes autofilling "subtitle" honeypot HOT 11
- New feature: Spam-Filtering on Post requests only HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from invisible_captcha.