Learn
Authorization
Admin Role I

Great work! The role-based authorization system is working. Users with an editor role have permissions to see the edit page, while users without that role do not.

Instructions

1.

In the User model, add a method named admin? that determines whether a user has an admin role on the site.

2.

Open db/seeds.rb. We’ve added a user named Freida with the role admin.

We should now be able to use the admin? method to check whether a user has an editor role. Enter the Rails console and type:

> freida = User.find_by(email: '[email protected]') > freida.admin?
Folder Icon

Sign up to start coding

Already have an account?