title: call partial with object from query call
body: <p>I've got a problem to get my partial working.</p>
  
  <p>I want to pass an object via a local variable to a partial, but I get a </p>
  
  <pre><code>undefined method `model_name' for NilClass:Class 
  </code></pre>
  
  <p>error all the time. But the variable is passed over because I can call it in the partial with .to_yaml, which gives me all the variables properties.</p>
  
  <p>But when I try to use it in a form_for I get that error.</p>
  
  <p>Maybe it has something to do with my db query. Because when i try to call it with another local variable there is no error. But my query should produce a single object, or am I wrong with that?</p>
  
  <p>Here is my show.html.erb:</p>
  
  <pre><code>&lt;%= @partneroffer = Partneroffer.where(:partner_id =&gt; @partner.id, :yearname_id =&gt; year.id).first  %&gt;
  &lt;%= render :partial =&gt; "form2", :locals =&gt; { :partneroffer =&gt; @partneroffer } %&gt;
  </code></pre>
  
  <p>And here is my partial (_form2.html.erb):</p>
  
  <pre><code>&lt;%= form_for partneroffer , :html =&gt; { :class =&gt; 'form-horizontal' } do |f| %&gt;
    &lt;%= f.label :partnerstatus_id, :class =&gt; 'control-label' %&gt;
    &lt;%= f.collection_select(:partnerstatus_id, Partnerstatus.all, :id, :name) %&gt;
    &lt;%= f.submit nil, :class =&gt; 'btn btn-primary' %&gt;
    &lt;%= link_to t('.cancel', :default =&gt; t("helpers.links.cancel")),
   partner_year_terms_path, :class =&gt; 'btn' %&gt;
  &lt;% end %&gt;
  </code></pre>