For inviting the new user by giving their mail addresses in text field(multipe email addresses), i need to validate the given email addresses format and need to show the proper error message.Here i am using the space between the each email addresses.(for example useremail@gmail.com useremail2@yahoo.com)Please guide me.
1)How to validate user email addresses format?.
2)How to check if the user doesn't use space between the two email addresses?.
3)Suggest some best way to do this.
i am using rails(2.3.X and ruby 1.8.7)
User controller
def invite_users
  if request.get?
    #render invite_users.html.erb
  elsif request.post?
    if !params[:email_ids].blank? && !params[:message].blank?
      @email_ids = params[:email_ids].split(/ |, |,/)
      @message = params[:message]
      @inviting_users = @email_ids.count
      @inviting_users.times do
        @all_emails = []
        @all_emails = @email_ids.shift
        activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join)
        UserNotifier.deliver_invite_users(@all_emails, @message,activation_code, current_company)
        end
     else
       flash[:notice] = "Please fill all the fields"
     end
  end
end
 
    