3

How can I send an email address to a Rails controller, as a param, via jQuery, to check whether it already is registered (as part of validation for a registration form)? When I try to parameterize it with jQuery, a . remains in the parameter and Rails truncates the parameter.

I wrote a simple function to substitute in a pattern that I then replace in the controller, but I can't shake the feeling that I'm doing this the wrong way. Is there a way to encrypt the email before sending it as a parameter and then decrypt it in the controller so that I can use it in a query?

Basically, I'm trying to do some simple pre-validation so that if a user attempts to register using an email that already is registered that they will receiving a warning before submitting the form, with a link to recover their password.

Clay
  • 2,949
  • 3
  • 38
  • 54
  • 1
    possible duplicate of [rails routing and params with a '.' in them](http://stackoverflow.com/questions/7276125/rails-routing-and-params-with-a-in-them) or http://stackoverflow.com/questions/7407947/rails-route-path-breaks-when-there-is-symbol-in-username or http://stackoverflow.com/questions/5768326/rails-query-string-with-a-period – mu is too short Feb 02 '12 at 01:06
  • I think that will help with the `.`. How about encryption? Is there a good way or acceptable way to encrypt the email address in jQuery/javascript before sending it as a param and then decrypt it in the controller so that it's not exposed in the URL? – Clay Feb 02 '12 at 17:46

1 Answers1

1

Just use JSON. And you will can send/receive not only email, but another fields and error messages.

Ximik
  • 2,435
  • 3
  • 27
  • 53