varvet / pundit

Minimal authorization through OO design and pure Ruby classes
MIT License
8.26k stars 627 forks source link

Method with ? in name throws no method errors in policy #634

Closed XXChester closed 4 years ago

XXChester commented 4 years ago

I have a method in my sessions controller called is_logged_in? and in the sessions policy I have the same method with the correct security logic associated with it. However, when I try to access the method, I get these errors because the policy cannot find the method: Minitest::UnexpectedError: NoMethodError: undefined method is_logged_in?? for #<SessionPolicy:0x007f9530200bd0>

Of course rails method cannot have multiple question marks so how do I tell my policy that this is the method?

XXChester commented 4 years ago

I also asked this on SO (https://stackoverflow.com/questions/59481372/method-with-in-name-throws-no-method-errors-in-pundit-policy). It was answered there, basically your API methods should not have a ?.

Closing.