# Help with DRY captcha

**URL:** <https://www.ruby-forum.com/t/help-with-dry-captcha/133621>\
**Category:** Rails\
**Created:** [April 2, 2008, 3:11am UTC](https://www.ruby-forum.com/t/help-with-dry-captcha/133621 "2008-04-02T03:11:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dino\_d](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5ac83/32.png) [@dino\_d](https://www.ruby-forum.com/u/dino_d)\
**Post date:** [April 2, 2008, 3:11am UTC](https://www.ruby-forum.com/t/help-with-dry-captcha/133621/1 "2008-04-02T03:11:01Z")

</div>

Hi everyone-

I’m wondering if someone can give me some design help in implementing  
a DRY captcha solution. Given that I have a captcha controller which  
can generate a unique hash, and a corresponding correct answer, I’d  
like to extend every form, and/or every CRUD operation with a  
captcha.

So, one approach I can think of off the top of my head is to add an  
attr\_accessor to each model that uses a captcha, and on edit, set it’s  
value to the unique hash. In the corresponding view, add a hidden  
field with the hash, and a text input for the attr\_accessor field.  
Then, on submit/update, perhaps in the model (before create, etc),  
look up the hash and see if the typed in answer matches.

Ok, so far, does this seem reasonable?

I’d like to go one step further, and simply add one line to each model  
and one line to each form partial like

acts\_as\_captchable

However, I have zero idea where to start writing my own plugin. Does  
this sound like the way to go? If so, can someone give me some  
pointers to reading materials and strategies to implement my own  
extension (this is a milestone for me, as I’m at the point where I may  
actually be able to write a plugin that someone else can use).

Thanks for any help,  
Dino
