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.
In the User model, add a method named
admin? that determines whether a user has an admin role on the site.
Open db/seeds.rb. We’ve added a user named Freida with the role
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: 'firstname.lastname@example.org') > freida.admin?