I have a moderator relationships table which assigns users as mods to groups by pairing their user id with the group id in the table.
I want only mods to be able to create a group.
I am trying to use the pundit gem to do this but i'm stuck on the documentation. It has in its PostPolicy example:
def update?
user.admin?
end
Is the admin method previously defined somewhere else?
and if it is why don't people just use that in the controller update method directly? e.g.
def update
if user.admin?
update
else
dont update
end
I'm building an app to learn rails. Need help wrapping my head around this one. I'm not sure if the pundit gem defines the admin method inside the policy class by itself or if i have to make the method. If i need to make the method why would I need the pundit gem when i can just use the admin method like in the example i did above?