The easiest way is to re-run the generator using rails g Rolify:Role
command, and overwrite the initializer file. Both the migration file and the role.rb
haven’t changed. In the config/initializers/rolify.rb
file, here are the deprecated settings:
-
role_cname
-
user_cname
By default, these settings were commented out, so you can safely remove them. If you changed them, you can remove them in the initializer file too. user_cname
is no longer used in 3.x, you don’t need it anymore. Add your custom role_cname
setting as argument of the rolify method you use in your User class. For instance, if you use Privilege
as Role
class, you should add this to your whatever your User
class is, let’s say Client
for the sake of example:
class Client < ActiveRecord::Base rolify :role_cname => "Privilege" end
If you use the default Role
class name, you don’t have to specify the :role_cname
argument.
If you use dynamic methods (user.is_admin?
like methods), you should turn it on using use_dynamic_shortcuts
method starting from rolify 3.0:
Rolify.configure do |c| c.use_dynamic_shortcuts end
The old fashion way still works though, but won’t work anymore if the setter method name is changed in a possible future. You’ve been warned :-)
Starting from 3.3 release, rolify supports Rails 3.2 and newer.
Mongoid callbacks are supported if Mongoid 3.1 and newer is installed.
Role model template when using Mongoid has been changed, you should re-run the generator.
Rails generator has been renamed to: rails g rolify
and arguments have been changed:
-
Role class name is now mandatory, User class name remains optional and its default is still
User
-
ORM optional argument is now
-o
or--orm=
For instance, here is a new rolify generator command example: rails g rolify Role
You can use rails g rolify --help
to see all available options.
Starting from rolify 3.3, to run the specs you should run: rake spec
or simply rake
.