ruby on rails custom function validate and post
===

I have create a `controller` named `Invites` and a `model` named `invite` and i have created a new function in the controller named request_invite which i want to use for users to enter their email address, validate it and that it does not exist in the invites table and then post it to the database

invites_controller.rb

    class InvitesController < ApplicationController
    
    	def request_invite
    		render_404 unless request.xhr?
    
    		@email = params[:get_invited_email]
    
    		if @email
    			flash[:notice] = "msg + insert"
    		else
    			flash[:notice] = "msg"
    		end
    
    	end
    
    end


invite.rb

    class Invite < ActiveRecord::Base
    
    end

i have not added resources in the routes file

form

	<%= form_tag(invite_request_path, :method => "post", :id => "landing_request_invite_form") do %>
		<%= text_field_tag 'get_invited_email', nil, :placeholder => 'Enter your email address' %>
		<%= submit_tag 'Get Invited', :id => "get_invited_btn" %>
	<% end %>

javascript

      $("#landing_request_invite_form").submit(function(e){
      	e.preventDefault();
        var form = $(this);
        var url = form.attr("action");
        var formData = form.serialize(); 
        $.post(url, formData, function(html) { 
            console.log('request done');
        });
        return false;
      });

how can i check that the email does not exist? do i use the .find() method?