README.md in access-granted-1.3.1 vs README.md in access-granted-1.3.3

- old
+ new

@@ -23,11 +23,11 @@ config.autoload_paths += %W(#{config.root}/app/policies #{config.root}/app/roles) ``` ### Supported Ruby versions -Because it has **zero** runtime dependencies it is guaranteed to work on all major Ruby versions MRI 1.9.3-2.2, Rubinius >= 2.X and JRuby >= 1.7. +Because it has **zero** runtime dependencies it is guaranteed to work on all major Ruby versions MRI `2.0` - `2.5`, Rubinius `>= 2.X` and JRuby `>= 1.7`. ## Summary AccessGranted is meant as a replacement for CanCan to solve major problems: @@ -228,9 +228,24 @@ "failed to access a post" else "failed to access something else" end end +``` + +You can also have a custom exception message while authorizing a request. +This message will be associated with the exception object thrown. + +```ruby +class PostsController + def show + @post = Post.find(params[:id]) + authorize! :read, @post, 'You do not have access to this post' + render json: { post: @post } + rescue AccessGranted::AccessDenied => e + render json: { error: e.message }, status: :forbidden + end +end ``` #### Checking permissions in controllers To check if the user has a permission to perform an action, use the `can?` and `cannot?` methods.