Learn

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?

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?