pundit_user not working

Created on 21 Dec 2013  路  3Comments  路  Source: varvet/pundit

Hi, tested with Pundit v. 0.2.1 . My application uses other names besides 'user' for user roles so as per docs I tried pundit_user in my controllers.

Here's a toy example that demonstrates the problem (for me at least):

class ThingysController < ApplicationController
  include Pundit

  def pundit_user
    WeirdlyNamedUser.new
  end

  def index
    @thingy = Thingy.new
    authorize @thingy
  end
end

When I go to /thingys I get

Name Error in ThingysController#index
undefined local variable or method `current_user' for #<ThingysController:0x007ff1f3d56a78>

Most helpful comment

or just do
alias_method :current_user, :my_strange_user_method

All 3 comments

0.2.1 isn't using the pundit_user method, it just uses current_user: https://github.com/elabs/pundit/blob/v0.2.1/lib/pundit.rb#L68

You might want to use Pundit from the master branch or wait for a new gem release.

or just do
alias_method :current_user, :my_strange_user_method

OK thanks for clarifying!

Was this page helpful?
0 / 5 - 0 ratings