title: Using ActionMailer in Rails to receive emails from forms
body: <p>I am trying to receive emails from a Contact Form using ActionMailer in Rails 5. But I am not sure on how send the params of the resource created on the form to the email on the receive method and send it to the email of the app.</p>
  
  <p>controllers/contacts_controller.rb:</p>
  
  <pre><code>class ContactsController &lt; ApplicationController
  
    def index
      @contact = Contact.new
    end
  
    def create
      @contact = Contact.new(contact_params)
      if @contact.save
        DefaultMailer.receive(@contact).deliver
        redirect_to root_path
      else
        render :new
      end
    end
  
    private
    def contact_params
      params.require(:contact).permit(:name, :email, :subject, :body)
    end
  end
  </code></pre>
  
  <p>mailers/default_mailer.rb:</p>
  
  <pre><code>class DefaultMailer &lt; ApplicationMailer
    default from: "atendimento@lcasystems.com.br"
  
    def receive(email)
      mail.create(subject: email.subject, body: email.body)
    end
  end
  </code></pre>
  
  <p>It gives a 500 server error and  says undefined method `humanize' for nil:NilClass in the receiver method.</p>