Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pundit_user not working #84

Closed
jdwolk opened this issue Dec 21, 2013 · 3 comments
Closed

pundit_user not working #84

jdwolk opened this issue Dec 21, 2013 · 3 comments

Comments

@jdwolk
Copy link

jdwolk commented Dec 21, 2013

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>
@tbuehlmann
Copy link

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.

@Kriechi
Copy link

Kriechi commented Dec 21, 2013

or just do
alias_method :current_user, :my_strange_user_method

@jdwolk
Copy link
Author

jdwolk commented Dec 21, 2013

OK thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants