You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw in the user policy example you have, you use:
class UserPolicy
attr_reader :current_user, :model
def initialize(current_user, model)
@current_user = current_user @user = model
end
def index?
@current_user.admin?
end
I thought the point of attr_reader was to set access to the local variable. If that's the case, why do you use '@' in the action methods? Shouldn't your notation be 'current_user.admin? in the action methods?
I'm trying to learn how to write scopes and getting very stuck with the examples I can find to this point. I think my struggles have something to do with the notation. I'd love to know why you use this format. It might help me understand what's going wrong for me.
The text was updated successfully, but these errors were encountered:
I saw in the user policy example you have, you use:
class UserPolicy
attr_reader :current_user, :model
def initialize(current_user, model)
@current_user = current_user
@user = model
end
def index?
@current_user.admin?
end
I thought the point of attr_reader was to set access to the local variable. If that's the case, why do you use '@' in the action methods? Shouldn't your notation be 'current_user.admin? in the action methods?
I'm trying to learn how to write scopes and getting very stuck with the examples I can find to this point. I think my struggles have something to do with the notation. I'd love to know why you use this format. It might help me understand what's going wrong for me.
The text was updated successfully, but these errors were encountered: