title: Action Mailer with form that accepts_nested_attributes with Rails/HAML
body: <p>My model setup:</p>
  
  <pre><code>class Contact &lt; ActiveRecord::Base
    belongs_to :restaurant
  end
  
  
  class Restaurant &lt; ActiveRecord::Base
    has_many :contacts
    accepts_nested_attributes_for :contacts
  end
  </code></pre>
  
  <p>Contact class, trying to target: <code>:email</code></p>
  
  <pre><code>class Contact &lt; ActiveRecord::Base {
                 :id =&gt; :integer,
         :first_name =&gt; :string,
          :last_name =&gt; :string,
               :role =&gt; :string,
              :email =&gt; :string,
              :phone =&gt; :string,
    :webmaster_email =&gt; :string,
      :restaurant_id =&gt; :integer,
         :created_at =&gt; :datetime,
         :updated_at =&gt; :datetime
  }
  </code></pre>
  
  <p>My create action:</p>
  
  <pre><code>  def create
      stripe_token = PayingCustomer.build(restaurant_params)
      @restaurant = Restaurant.new(restaurant_params)
      @restaurant.payment_profile_id = stripe_token.id
      @restaurant.generate_token
      respond_to do |with|
        if @restaurant.payment_profile_id != nil &amp;&amp; @restaurant.save
          RestaurantMailer.signup_confirmation(@restaurant).deliver
          with.html {redirect_to restaurants_path(token: @restaurant.token)}
        else
          with.html {render :new }
        end
      end
    end
  </code></pre>
  
  <p>I'm not sure how to target the email entered on form below:</p>
  
  <pre><code> =form_for @restaurant, html: {id: 'signup-form', multipart: true} do |f|
        =field_set_tag %q{First, tell us about your restaurant.}, class: 'restaurant' do
          =label_tag '', '', for: 'restaurant_name'
          =f.text_field :name, placeholder: 'Restaurant Name'
          =label_tag '', '', for: 'restaurant_address'
          =f.text_field :address, placeholder: 'Street Address'
          =label_tag '', '', for: 'restaurant_city'
          =f.text_field :city, placeholder: 'City'
          =label_tag '', '', for: 'restaurant_state_province'
          =f.text_field :state_province, placeholder: 'State/Province'
          =label_tag '', '', for: 'restaurant_country'
          =select_tag 'restaurant[country]', "&lt;option value='canada'&gt;Canada&lt;/option&gt;&lt;option value='usa'&gt;United States&lt;/option&gt;".html_safe, id: 'country'
  
        =field_set_tag %q{Provide us with your contact info.}, class: 'contact' do
          =f.fields_for :contacts do |contact_fields|
            =label_tag '', ''
            =contact_fields.text_field :first_name, placeholder: 'First Name'
            =label_tag '', ''
            =contact_fields.text_field :last_name, placeholder: 'Last Name'
            =label_tag '', ''
            =contact_fields.text_field :role, placeholder: 'Role at Restaurant'
            =label_tag '', ''
            =contact_fields.text_field :email, placeholder: 'Email'
            =label_tag '', ''
            =contact_fields.text_field :phone, placeholder: 'Phone'
            =label_tag '', ''
            =contact_fields.text_field :webmaster_email, placeholder: "Webmaster's Email (optional)"
  </code></pre>
  
  <p>My target is <code>=contact_fields.text_field :email, placeholder: 'Email'</code></p>
  
  <p>I'm trying to find out how I would write this in my mailer, with current setup, I'm getting <code>wrong number of arguments (1 for 2)</code></p>
  
  <p>My problem is right here:</p>
  
  <pre><code>class RestaurantMailer &lt; ActionMailer::Base
    default from: "from@example.com"
  
    def signup_confirmation(restaurant, contact) 
      @greeting = "Hi"
      @restaurant = restaurant  
      @contact = contact
      mail to: contact.email, subject: "Sign up Confirmation"
    end
  end
  </code></pre>
  
  <p>Edit:</p>
  
  <pre><code>  def signup_confirmation(restaurant)
      @greeting = "Hi"
      @restaurant = restaurant
      @contact = restaurant.contact
      mail to: @contact.email, subject: "Sign up Confirmation"
    end
  </code></pre>
  
  <p>Results in: </p>
  
  <pre><code>NoMethodError in RestaurantsController#create
  undefined method `contact' for #&lt;Restaurant:0x007fd686c593b0&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>