title: Accepting nested attributes on a belongs_to association
body: <p>I have a complex form for scheduling events. Here are the abbreviated associations:</p>
  
  <pre><code>class Event &lt; ActiveRecord::Base
    belongs_to :client
    accepts_nested_attributes_for :client, :reject_if =&gt; lambda { |a| a[:name].blank? }
  end
  
  class Client &lt; ActiveRecord::Base
    has_many :events
    has_many :questions, :dependent =&gt; :destroy
    accepts_nested_attributes_for :questions, :reject_if =&gt; lambda { |a| a[:content].blank? }
  end
  </code></pre>
  
  <p>The form is creating a new event and I have the following structure:</p>
  
  <pre><code>- form_for @event do |event_form|
      %select=collection_select(client_options_for_select, :options, :group_name, :id, :name, @event.client_id)
  
     - event_form.fields_for :client do |client|
       = client.text_field :name
  
       - client.fields_for :questions do |question|
         = question.text_field :content
  </code></pre>
  
  <p>The client already exists and is chosen from a select menu. An observer renders the nested attributes form by setting the client variable in a controller action and then rendering the partial.</p>
  
  <p>Here is the error I'm getting:</p>
  
  <pre><code>ActionView::TemplateError (wrong number of arguments (0 for 1)) on line #1 of app/views/proceedings/_questions.html.haml:
  1: - event_form.fields_for :client do |client|
  
  app/views/proceedings/_questions.html.haml:1:in `form'
  app/views/proceedings/_questions.html.haml:1:in `_run_haml_app47views47events47_client_questions46html46haml_locals_client_questions_object'
  haml (3.0.21) rails/./lib/haml/helpers/action_view_mods.rb:13:in `render'
  app/controllers/proceedings_controller.rb:261:in `__instance_exec0'
  app/controllers/proceedings_controller.rb:260:in `corp_client_questions'
  app/controllers/proceedings_controller.rb:258:in `corp_client_questions'
  </code></pre>
  
  <p>I'm having problems (I think) with the belongs_to association between Event and Client. I don't know if Event can accept nested attributes of Client when the Event belongs_to the Client. I've always done it the other way around (Client accepts nested attributes of Event).</p>
  
  <p>Any ideas? I can elaborate if you need more code or background. Thanks!</p>
  
  <p>Update: Added controller code as requested.</p>
  
  <pre><code>def client_questions
  if params[:client_id].blank?
    render_no_client_questions
  elsif @client = Client.find(params[:client_id]) and @client.is_unspecified?
    render_no_client_questions
  else
    respond_to do |format|
      format.js {
        render :update do |page|
          page[:client_questions].replace_html :partial =&gt; 'client_questions', :layout =&gt; false
        end
      }
    end
  end
  </code></pre>
  
  <p>end</p>