title: ruby on rails if email exist return success
body: <p>controller function</p>
  
  <pre><code>def request_invite
  
          if !request.xhr?
                  render_404
                  return
          end
  
          @invitation = Invite.new(params[:invite])
  
          if @invitation.save
              @return = { :error =&gt; false, :response =&gt; "Thank you" }
          else
                  error_message = '&lt;div class="error_message"&gt;' + @invitation.errors.full_messages.map {|error| "&lt;p&gt;#{error}&lt;/p&gt;"}.join + "&lt;/div&gt;"
              @return = { :error =&gt; true, :response =&gt; error_message } 
          end
  
          render :json =&gt; ActiveSupport::JSON.encode( @return )
  
  end
  </code></pre>
  
  <p>model</p>
  
  <pre><code>class Invite &lt; ActiveRecord::Base
  
      validates :email, :presence =&gt; true, :uniqueness =&gt; true
  
      validates_format_of :email, :with =&gt; /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
  
  end
  </code></pre>
  
  <p>this will either save to the db and show a success msg or throw an error if exist...</p>
  
  <p>i want to show the success msg even if the email already exist in the database so it wont show that the email has already been added</p>