What i have done is the followring (it is sort of a summary or a
combination of what @freddy and @ramon said):
first i check that the email is in correct format using this chunk of
code:

# validate that password and confirm_password match, and that email is
proper format
  def validate_on_create
    @email_format = Regexp.new(/^([EMAIL 
PROTECTED])@((?:[-a-z0-9]+\.)+[a-z]{2,})
$/)
    errors.add(:email, "must be a valid format") unless
@email_format.match(email)
    errors.add(:confirm_password, "does not match") unless password ==
confirm_password
  end

which is in the user.rb file
then in my controller i send an email to the user when they register
with a link back to my controller with a hash at the end of it that is
constructed through many ways (google tutorials on this, there are
plenty) and my controller validates that the hash is correct and sets
a boolean attribute of the user (call it email_confirmed if you will)
to true. So the user can not log in to the site unless they have
confirmed their email.

The other approach I have seen many site implement is to send the user
their password to their email, which means they have to provide a
valid email address to be able to log in. I am personally not very
comfortable with sending a password through an email so I prefer to
stay away from that method.

But again, these are not perfect methods, they're just a way to do
what you want to get done. Maybe if OpenID picks up we won't have that
problem anymore.

On Oct 11, 3:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Hi,
>
>    I have one small question. I want to check for existence of email
> address. Means if user types "[EMAIL PROTECTED]", my model should
> throw an error to the user saying "email doesn't exist please check it
> once".  How I can do this??
>
> Thanks,
> Ramu
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to