title: Rails User Sign Up Mail Confirmation
body: <p>I'm trying to create a mailer that sends out an email whenever a user signs up. Pretty simple but I'm new to rails.</p>
  
  <p>I have a site that already creates the user. I have a login and sign up page that works correctly, but need some help creating a mailer that sends out an email confirmation link and possibly an option to send out these emails without the user signing up like make a separate page for user invitations.</p>
  
  <p>I've generated a model invitation.rb</p>
  
  <pre><code>  class Invitation &lt; ActiveRecord::Base
    belongs_to :sender, :class_name =&gt; 'User'
    has_one :recipient, :class_name =&gt; 'User'
  
    validates_presence_of :recipient_email
    validate :recipient_is_not_registered
    validate :sender_has_invitations, :if =&gt; :sender
  
    before_create :generate_token
    before_create :decrement_sender_count, :if =&gt; :sender
  
    private
  
    def recipient_is_not_registered
      errors.add :recipient_email, 'is already registered' if User.find_by_email(recipient_email)
    end
  
    def sender_has_invitations
      unless sender.invitation_limit &gt; 0
        errors.add_to_base 'You have reached your limit of invitations to send.'
      end
    end
  
    def generate_token
      self.token = Digest::SHA1.hexdigest([Time.now, rand].join)
    end
  
    def decrement_sender_count
      sender.decrement! :invitation_limit
    end 
    #attr_accessible :sender_id, :recipient_email, :token, :sent_at
  end
  </code></pre>
  
  <p>and my invitiation_controller.rb</p>
  
  <pre><code>class InvitationsController &lt; ApplicationController
    def new
      @invitation = Invitation.new
    end
  
    def create
      @invitation = Invitation.new(params[:invitation])
      @invitation.sender = current_user
      if @invitation.save
        if logged_in?
          Mailer.deliver_invitation(@invitation, signup_url(@invitation.token))
          flash[:notice] = "Thank you, invitation sent."
          redirect_to projects_url
        else
          flash[:notice] = "Thank you, we will notify when we are ready."
          redirect_to root_url
        end
      else
        render :action =&gt; 'new'
      end
    end
  end
  </code></pre>
  
  <p>What else do I need to edit? how do I hook this up to an already existing user signup and login that is working fine?</p>