title: How do I resolve a "No Method Error" in my post controller. Devise, Pundit, Blogging app
body: <p>In trying to set-up policies for my practice app. I'm running into a "No Method Error" in my posts controller. </p>
  
  <p>If we zero in on the post controller and my update method here is the code. </p>
  
  <pre><code> def update
  authorize @post
  respond_to do |format|
  if @post.update(post_params)
  
    format.html { redirect_to @post, notice: 'Post was successfully updated.' }
    format.json { head :no_content }
    #redirect_to @post
  
  else
    render :edit
    format.html { render action: 'edit' }
    format.json { render json: @post.errors, status: :unprocessable_entity }
  end
  end
  </code></pre>
  
  <p>end</p>
  
  <p>As you can see nothing really special. Just a HTML and JSON rendering of the updated page. </p>
  
  <p>The <code>authorize</code> code points to a helper in pundit that looks up the access policies. </p>
  
  <p>Defined in my Admin.rb model i have. </p>
  
  <pre><code>def editor?
      self.role == 'editor'
    end
  </code></pre>
  
  <p>The <code>authorize</code> code looks up the policy that corresponds to the method name. It looks in the policy class and starts applying the business rules found here. And here is where the problems start. </p>
  
  <p>I get to <code>def update?
      @admin.editor?
    end</code></p>
  
  <p>And it says <code>undefined method 'editor?' for #&lt;Class:0x007ffb7fa4f6a0&gt;</code></p>
  
  <p>The code is on the policy branch on Git : <a href="https://github.com/wmuengineer/portfolio/tree/policy" rel="nofollow">https://github.com/wmuengineer/portfolio/tree/policy</a></p>