Breaking changes:
-
Support strict
with_role
queries. Note this changes behaviour of with_role when running in strict mode to behave as previously documented. #543 describes the behaviour change. -
Dropped support for Ruby 2.3 and 2.4
Improvements:
-
Updated ActiveRecord adapters implementation of
in
to utilise a subquery instead of two queries
5.3.0 will be the last version to support Ruby < 2.5 and Rails < 5.2. Support for these will be dropped in the next major release.
-
Fix deprecation warning in Ruby 2.7
-
Add Rails 6 support to migration generator
-
Significant ActiveRecord performance improvements to
add_role
andwithout_role
-
Mongoid fix and performance improvement and to
roles_name
-
Make it safe to call
Thing.with_role(:admin, user)
with new record
-
Fix regression in generator around belongs_to options compatibility
-
Update version of database_cleaner
-
Update initializer.rb to include the remove_role_if_empty option and description
-
Allow inverse_of option on rolify method
-
Fix the code-climate-reporter issue that’s causing travis to fail
-
Remove a separate index for the name column
-
Fix migration generator for AR 5.x
-
Fixed ambiguous column error
-
Rails 5 Support (thanks @lorefnon)
-
Fix user handling in generator (thanks @lorefnon)
-
Fix quoting issues (thanks @lorefnon)
-
Improvements to dynamic module loading (thanks to @DmitryKK)
-
Fix migration warning showing when it shouldn’t
-
Add role lazy-loading
-
Add has_cached_role and has_cached_strict_role to project. See: github.com/RolifyCommunity/rolify#cached-roles-to-avoid-n1-issue
-
Update specs to pass with all Mongoid version.
-
Fix a regression in the dynamic method loader.
-
added ‘without_role` method for resources and classes
-
fix ‘has_role?` with :any and an unsaved user
-
rename the ‘with_role` method on a resource to `find_as`
-
add a strict parameter to check only roles that were set without supers.
-
Increasing version number to 4.0.0 for semantic versioning since ‘has_role` was removed in 3.5.0
-
Fix spec to pass.
-
Fix dynamic shortcuts being set before migration.
-
Fixed regression in RolifyGenerator
-
Updated dependencies
-
Removed ‘has_role` method alias for `add_role`
-
Fixed regression in caching system
-
Fix deprecation warning about timestamp on specs
-
Copy Kernel#capture helper from Rails
-
Add validation on Role.resource_type
-
Fixed issue with migrations being generated without a file extension.
-
Updated spec tests to work with Travis CI on Ruby up to 2.1.2 and Rails 4.1.x
-
Made it possible for inheritance of resources.
-
Fixed small bugs throughout project.
-
fixed an initializer bug preventing the rails app to boot
-
enhanced documentation regarding
with_role
method (thanks to @vicomte) -
added
select(:id)
in SQL subquery used byin
method in ActiveRecord adapter (thanks to @ryanaip and @badaboda) -
improved speed when removing roles using
LIMIT(1)
instead ofCOUNT
(thanks to @yankovski) -
fixed travis builds for rubinius and mongoid
-
fixed sanity check running before
Rolify.config
to ensure roles table exists -
fixed
has_any_role?
to work with unsaved records (thanks to @mhw) -
fixed specs for Mongoid
-
DEPRECATION NOTICE:Rails 3.1 support dropped: if you use Rails 3.1, please stick to rolify 3.2
-
code cleanup in finders methods
-
generators rewritten entirely. now using ActiveRecord/Mongoid model generator to create Role model
-
added rspec matchers for detailed spec error messages (thanks to @delwyn)
-
clean up specs (thanks to @delwyn), removed subject and let declarations in before(:all) block
-
roles query needs 1 DB hit instead of 1 up to 3 (thanks to @terraplane)
-
remove nil entries from ResourceAdapter#resources_find when using Mongoid adapter (thanks to @daviscabral)
-
fixed a bug regarding redundant index for Mongoid Role model (thanks to @rschultheis)
-
added support for rolify and resourcify methods on the same model class (specs by @amer)
-
added support for namespaced models (thanks to @intrica)
-
fixed compatibility issue with squeel when using symbols as role parameters (hint by @f3ndot)
-
now raises a warning in the initializer if migration has not been run
-
add support for primary key different than ‘id’ for resource Model (thanks to @rafaeldl)
-
Rails 4 (thanks to @adammathys) and ruby 2.0 compliant
-
configured travis-ci to run the specs on Rails 3.2/4.0 and Rubies 1.9.3/2.0/rbx/jruby
-
added code climate to check for code smell
-
DEPRECATION NOTICE: Ruby 1.8 support dropped ! Mongoid 3.0 only supports MRI 1.9.3, and HEAD, and JRuby 1.6.0+ in 1.9 mode
-
removed
dynamic_shortcuts
arguments from the generator-
to use dynamic shortcuts feature when you’re using ActiveRecord, you have to enable it after running rake db:migrate as it relies on the roles table
-
-
support for Mongoid 3.x (thanks to @Leonas)
-
new class methods on the User class to find users depending on roles they have
-
added scopes to Role class to be able to fetch global, class scoped and instance scoped roles for a specific user
-
deletions of n-n relation are unreliable with Mongoid. Removing ids instead (thanks to @nfo)
-
has_role?
method now supports new instance (i.e. record not saved in the database yet) (thanks to @demental) -
added association callbacks
(before|after)_add
,(before|after)_remove
onrolify
method (thanks to @shekibobo) -
added ability to pass an array of roles to
Resource.with_role()
, aliased byResource.with_roles()
(thanks to @lukes) -
added option to have roles be destroyed by default if parent resource is destroyed (thanks to @treydock)
-
added new method
only_has_role?
to check if user has only a specific role (thanks to @jalcine) -
better edge cases covering in the specs
-
fixed a bug regarding the loading order of the railtie when using Mongoid ORM and other gems using initializer files (thanks to @stigi)
-
fixed double quote syntax when using MySQL
-
fixed a nasty bug regarding class level queries (thanks to @kamrulhassan)
-
fixed uninitialized constant error in scopify method
-
documentation improvement
-
Mongoid adapter optimization
-
adapter code refactoring
-
generator now adds the role class name to the rolify method injected in the user class
-
fixed a bug on the generator when using a 2 words Camel case for the Role class name
-
DEPRECATION NOTICE:
has_role
andhas_no_role
have been depecrated. They are replaced byadd_role
andremove_role
-
some internals cleanup (backward compatible)
-
stop requiring
active_record
inrolify.rb
to prevent other gems ORM detection issue -
fixed a bug when removing a role to the user using Mongoid adapter
-
added indexes to generator for mongoid (thanks to @stigi)
-
fixed a bug regarding with_role method on resource classes (thanks to @nfo)
-
support for Mongoid
-
roles search on resources on instance level (e.g.
Forum.first.roles
) and class level (e.g.Forum.with_role("admin", user)
) -
heavy lifting and redesign of the library, code and specs refactoring
-
enhanced drastically specs coverage: 1001 examples !
-
fixed another bug occurring when dynamic shortcuts is enabled
-
display now a README file after running the generator to show the next setup steps
-
fixed a backward incompatible change introduced in Rails 3.2 release (
find_or_create_by_* generated methods
)
-
fixed a bug in the initializer file regarding dynamic shortcuts
-
added syntactic sugar:
grant
andrevoke
are aliases forhas_role
andhas_no_role
-
check if RUBY_ENGINE is defined in the gemspec to be able to use jdbc with JRuby for SQLite
-
improved performance of
has_all_roles?
method using one single DB query instead of doing one DB lookup per argument-
significant speed-up when requesting with many arguments
-
database choice can mitigate the results
-
-
clean up the initializer code
-
using a DSL to configure the library
-
setting defaults for User and Role classes
-
dynamic shortcuts feature is now disabled by default. To turn it on:
-
set it to true in the initializer file
-
uncomment the
extend Rolify::Dynamic
line in the User class
-
-
detecting if it’s loaded by Rails::Server or Rails::Console
-
-
now also running on Rubinius, JRuby, REE and Ruby 1.8. all specs pass successfully, yeah !
-
fixed a strange bug, probably rails related (thanks to @scottkf)
-
when using rails in development mode, the
config.cache_classes = false
makes the role class to be loaded at every call and can lead to aAssociationTypeMismatch
-
use of
role_ids
array instead of theroles
association
-
-
now running on JRuby (specs are still failing for JRuby though)
-
added a spec to test the rails generator using ammeter gem
-
Gemfile cleanup, moved all dependencies in gemspec instead
-
edited the dependency to Rails 3.1 and newer, now that Rails 3.1 has been released
-
new role scoping capabilities
-
instance level :
user.has_role "moderator", Forum.first
(already supported in previous release). user has the moderator role only on that Forum in particular -
class level :
user.has_role "moderator", Forum
. User has the moderator role on all instances of Forum -
global level :
user.has_role "moderator"
(already supported in previous release). User has the moderator role globally (e.q. on all resources)
-
-
new scoped query capabilities
-
user.has_role? "moderator", Forum.first
(already supported in previous release). asks if the user has the moderator role on Forum.first instance -
user.has_role? "moderator", Forum
. asks if the user has the moderator role on all Forum instances -
user.has_role? "moderator"
(already supported in previous release). asks if the user has the global moderator role -
user.has_role? "moderator", :any
. asks if the user has at least one moderator role no matter the scope is (instance, class or global).
-
-
added a new parameter to disable dynamic shortcut methods due to potential incompatibility with other gems using method_missing with the same pattern
-
add
Rolify.dynamic_shortcuts = false
in the initializer file or -
use the generator command with a third parameter:
-
rails g rolify:role Role User false
-
-
-
removed the railtie as it created more problems than it solved
-
code refactoring to do some speed improvements and code clean up
-
added a lot of specs to improve tests coverage
-
wrote a tutorial showing how to use rolify with CanCan and Devise
-
rolify is now on travis-ci to monitor build status
-
added a method_missing to catch newly created role outside the current ruby process (i.e. dynamic shortcut methods are not defined within this process)
-
dynamic shortcut is created on the fly in the method_missing to avoid extra method_missing for the same dynamic shortcut
-
check if the role actually exists in the database before defining the new method
-
first call is slower due to method_missing but next calls are fast
-
avoid strange bugs when spawning many ruby processes as the dynamic shortcut methods were only defined in the process that used the
has_role
command
-
-
custom User and Role class names support
-
can now use other class names for Role and User classes
-
fixed generators and templates
-
join table is explicitly set to avoid alphabetical order issue
-
-
created a new railtie to load the dynamic shortcuts at startup
-
fixed a nasty typo on a variable name and added a spec to make it never happen again
-
dynamic shortcuts support
-
creates automatically new methods upon new role creation (or at startup for a Rails app)
-
has_role "admin"
will create a method calledis_admin?
-
has_role "moderator", Forum.first
will create 2 methods:* <tt>is_moderator_of?(resource)</tt> * <tt>is_moderator?</tt>
-
-
removing role support
-
has_no_role
removes a global role or a role scoped to a resource -
Please note that trying to remove a global role whereas the user a role with the same name on a resource will remove that scoped role
-
Trying to remove a role scoped to a resource whereas the user has a global role won’t remove it
-
-
multiple roles check:
-
has_all_roles?
returns true if the user has ALL the roles in arguments -
has_any_role?
returns true if the user has ANY the roles in arguments
-
-
fixed the generator to include the lib
-
fixed the migration file with missing polymorphic field
-
added some examples in documentation
-
first release