Repository navigation
Migration guide to version 2.0.0 #52
Locked
enjaku4
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This guide is intended to help you migrate your code to the second version of Rabarber.
There are a few breaking changes in the new version, but they are minor and should be easy to fix.
1. Configuration option
when_unauthorizedis replaced with an overridable controller methodAs it makes more sense to handle unauthorized access in the controller,
when_unauthorizedconfiguration option has been removed. Instead, you can overridewhen_unauthorizedmethod in your controller to handle unauthorized access. Moreover, it adds more flexibility as you can handle unauthorized access differently in different controllers.If you are using
when_unauthorizedconfiguration option, you need to remove it and override the privatewhen_unauthorizedmethod in your controller.For example, if you have the following configuration:
You'll likely want to have something like this in your
ApplicationController:2. Configuration options
when_actions_missingandwhen_roles_missingare removedThe configuration options
when_actions_missingandwhen_roles_missinghave been removed (see this topic). If you are using these options, you simply need to remove them from your configuration.The default behavior of raising an error when non-existent actions are passed to
grant_accessmethod is preserved, as such a case is clearly the programmer's mistake and the programmer should be notified about it.When non-existent roles are passed to
grant_accessmethod, nothing happens, as it is perfectly fine if a role does not exist (e.g., was removed at runtime or hasn't been added yet).3.
Rabarber::Role.assignees_foris nowRabarber::Role.assigneesThe method
Rabarber::Role.assignees_forhas been renamed toRabarber::Role.assignees. If you're using it, you need to change the method name in your code.All reactions