title: Send User email after creating a post, with Action Mailer
body: <p>I have a User model (with Devise), and a Post model that belongs to the user. I used <a href="http://railscasts.com/episodes/61-sending-email-revised" rel="nofollow">this railscast (pro)</a> to send the User an email after creating an account</p>
  
  <p>I created a "NewPostMailer"</p>
  
  <p>This is my mailer:</p>
  
  <pre><code>class NewPostMailer &lt; ActionMailer::Base
    default :from =&gt; "email@gmail.com"
  
    def new_post_email(user)
      @user = user
      @url = "http://localhost.com:3000/users/login"
      mail(:to =&gt; user.email, :subject =&gt; "New Post")
     end
  end
  </code></pre>
  
  <p>My posts_controller:</p>
  
  <pre><code>  def create
      @post= Post.new(params[:post])
  
      respond_to do |format|
        if @deal.save
          NewPostMailer.new_post_confirmation(@user).deliver
          format.html { redirect_to @post, notice: 'Post was successfully created.' }
  </code></pre>
  
  <p>post.rb</p>
  
  <pre><code>  after_create :send_new_post_email
  
    private
    def send_new_post_email
      NewPostMailer.new_post_email(self).deliver
    end
  </code></pre>
  
  <p>What do I have to change to send the User an email after he creates a Post. Thanks.</p>