title: Partial path error because of nil
body: <p>I am working on a project and I just introduced polymorphism for posting text Posts and photo Posts.</p>
  
  <p>When I try to post an image I get this error: "'nil' is not an ActiveModel-compatible object that returns a valid partial path."</p>
  
  <p><img src="https://i.stack.imgur.com/vrOgg.png" alt="enter image description here"></p>
  
  <p>The first show file (app/views/dashboards/show.html.erb) with code:</p>
  
  <pre><code>&lt;%= form_for @text_post do |form| %&gt;
  &lt;%= form.text_field :body, placeholder: 'Post content here' %&gt;
  &lt;%= form.submit 'Post Title!' %&gt;
  &lt;%end%&gt;
  
  &lt;%= form_for @photo_post do |form| %&gt;
  &lt;%= form.file_field :image %&gt;
  &lt;%= form.submit 'Post Image!' %&gt;
  &lt;%end%&gt;
  
  &lt;%= render @posts %&gt;
  </code></pre>
  
  <p>which leads to this at app/views/photo_posts/_photo_post.html.erb with the following code:</p>
  
  <pre><code>&lt;%= image_tag photo_post.image.url(:post) %&gt;
  </code></pre>
  
  <p>The app/views/posts/_post.html.erb which causes problem is:</p>
  
  <pre><code>&lt;%= div_for post do %&gt;
  &lt;%= link_to post.user.username, post.user %&gt;
  posted
  &lt;%= render post.content %&gt;
  &lt;%= link_to time_ago_in_words(post.created_at), post %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Sorry if the details I provide is insufficient, I am a new ROR developer. If you want, you can fork or check the project from <a href="https://github.com/stefioan/imageTitles" rel="nofollow noreferrer">here</a>, (I pushed so you can check for the error).</p>
  
  <p>Any help/guidance is greatly appreciated!</p>