-
add another role to your roles table with the privilege "zoo keeper", the description of this role is "medium access"
-
you should now have 3 levels of roles
- admin: can do everything (add zoos and animals etc)
- zoo keeper: can do some stuff (like add an animal, edit an animal, delete an animal, but they can't create, edit or delete zoos)
- normal level: can't do anything, can't add animals
- note that a normal level user can view pages like show animal and show zoos π¦
-
add a route called
'/zoo-keepers', it should have an associated controller and action -
on this page add a button that can be clicked, the button should be a "become a zoo keeper button"
- this button when clicked will change the users role from normal level to zoo keeper level
- this will also require adding a new update action to your controller
-
add the associated pundit code to ensure controller actions are protected at different role levels
-
test to see that all your different roles and pundit authorisation is working
- make sure a normal level user can only view the index and show pages
- make sure a zoo keeper user can add, update and delete animals but they can't add, update or delete zoos
- make sure an admin user can do everything
- make sure that when you type the url in the pages are not accessible, for instance if a normal level user tries to access the
'localhost:3000/zoos/new'page it should throw an error
- add a custom error page for these pundit related errors, you can find out how to do this is matt's documentation on pundit