title: Rails action mailer if statements
body: <p>I'm trying to put some logic into my mailer.  Basically, I have a dozen boolean fields in one of my models and for each field that is true, I want an email to be sent to a specific address.  The model with the boolean fields is called Ecn.  This is my notifier file:</p>
  
  <pre><code>class EcnNotifier &lt; ActionMailer::Base
    default from: "engineering_notices@wilfley.com"
  
    def submitted(ecn)
      @ecn = ecn
      @email_list = EmailList.all
      if @ecn.distribute_engineering?  
          mail to: "abc@gmail.com", subject: 'ECN approvald' 
      else
  
      end
      if @ecn.distribute_purchasing? 
          mail to: "123@gmail.com", subject: 'ECN approval' 
      else
  
      end
      mail to: "aaa@test.com", subject: 'ECN approval'
    end
  end
  </code></pre>
  
  <p>And the action I've created in my controller looks like this:</p>
  
  <pre><code>  def submit
  
      @ecn = Ecn.find(params[:id])
  
      respond_to do |format|
        EcnNotifier.submitted(@ecn).deliver
        format.html { redirect_to ecns_url, alert: "Ecn has been submitted for approval." }
        format.json { render json: @ecns }
      end
    end
  </code></pre>
  
  <p>An email gets sent automatically to aaa@test.com, but regardless of whether or not the distribute_engineering and distribute_purchasing are true, an email is not sent to the other addresses.  I'm assuming I'm incorrectly accessing my object instance, but I'm not sure where I'm going wrong.</p>