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>
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!
Most helpful comment
or just do
alias_method :current_user, :my_strange_user_method