views:

44

answers:

2

I like to determine if a visitor has already submitted a form.

I was thinking of doing a couple of things:

  • cookie
  • ipaddress
  • requiring login (much less desirable since the signup barrier might dissuade visitors)

Is there a ROR gem for this? If so please post a link.

Thanks

+1  A: 

How are you intending on saving the data?

If you're planning on putting this into a model, great. Then you can create some form of unique value (I'd probably base it on an MD5 of IP address and user agent), store that in a field, and require it to be unique for each submission.

There probably is a gem for this, but it's pretty simple anyway.

If you're not putting it into a model, I think we need more details of what your intentions are.

Stephen Orr
I was planning on putting in a model for that reason. I also wanted to use a model so I wouldn't have to write sql. (use the abstraction while its there right? :) )
cbrulak
Absolutely, use the abstraction while it's there! You can always override the default SQL Rails will use later, if you need to. Hope this helped anyway.
Stephen Orr
sure did, +1 for it :)
cbrulak
A: 

This sounds like a great opportunity to use HTML5's local storage engine.

You can store up to ~5MB and i'ts persistent.

YUI has a good wrapper for it.

http://developer.yahoo.com/yui/storage/

RobB