← Back to Upcase

Still getting a _photo_shouts.html.erb partial error


(Ryan Waits) #1

Here is my photo_shouts controller:

class PhotoShoutsController < ApplicationController
      def create
        content = build_content
        shout = current_user.shouts.build(content: content)
        if shout.save
          redirect_to dashboard_path
        else
          flash.alert = 'Can\'t shout BLANKS'
          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

in my _photo_shout.htm.erb partial:

<%= image_tag photo_shout.image.url(:shout) %>

I am still getting a partial error in the browser. Could be a one off, but I’ve been reviewing the video over and over, not sure where I’m goin wrong.


(Derek Prior) #2

@ryanwaits, what’s the error?


(Ryan Waits) #3

@derekprior I am still getting the:

‘nil’ is not an ActiveModel-compatible object. It must implement :to_partial_path.


(Joel Quenneville) #4

You are trying to render a nil object. You probably have an undefined/nil instance variable.