Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy am I getting 'nil' is not an ActiveModel-compatible object. It must implement :to_partial_path error?
    primarykey
    data
    text
    <p>Why am I getting the following error?</p> <blockquote> <p><code>nil</code> is not an ActiveModel-compatible object. It must implement :to_partial_path. </p> </blockquote> <p>I think the error may relate to the tutorial I'm following is using Rails 3.2 while I'm using Rails 4.</p> <p>Here is the model code:</p> <pre><code>class DashboardsController &lt; ApplicationController def show @text_shout = TextShout.new @photo_shout = PhotoShout.new @shouts = current_user.shouts end end class PhotoShoutsController &lt; ApplicationController def create content = build_content shout = current_user.shouts.build(content: content) if shout.save redirect_to dashboard_path else flash.alert = "Could not shout." redirect_to dashboard_path end end private def build_content PhotoShout.new(photo_shout_parameters) end def photo_shout_parameters params.require(:photo_shout).permit(:image) end end </code></pre> <p>Here is the view code with the error occurring on the _shout.html partial</p> <pre><code># app/view/dashboards/show.html.erb &lt;%= form_for @text_shout do |form| %&gt; &lt;%= form.text_field :body, placeholder: 'Shout content here' %&gt; &lt;%= form.submit 'Shout' %&gt; &lt;% end %&gt; &lt;%= form_for @photo_shout do |form| %&gt; &lt;%= form.file_field :image %&gt; &lt;%= form.submit 'Shout' %&gt; &lt;% end %&gt; &lt;%= render @shouts %&gt; # app/view/shouts/_shout.html.erb &lt;%= div_for shout do %&gt; &lt;%= link_to shout.user.username, shout.user %&gt; shouted +---------------------------------+ &lt;%= render shout.content %&gt; &lt;--| ERROR "nil' is not an Active " | | "Model-compatible object" | +---------------------------------+ &lt;%= link_to time_ago_in_words(shout.created_at), shout %&gt; &lt;% end %&gt; # app/views/photo_shouts/_photo_shout.html.erb &lt;%= image_tag photo_shout.image.url(:shout) %&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload