Top "Cancan" questions

The CanCan gem offers a straight forward and flexible way to define what a user can and cannot do.

Access CanCan's `can?` method from a model

You can get the current_user's permissions from a view or controller using can? in this fashion: <% if can? :…

ruby-on-rails cancan
Using cancan to prevent access to controller

I have an admin controller and I want that only users that are defined as admin would have access to …

authorization ruby-on-rails-3 cancan
CanCan explanation of load_and_authorize_resource

I would know how the load_and_authorize_resource works inside. I searched the github page Link and tried to …

ruby-on-rails ruby-on-rails-3 ruby-on-rails-4 cancan
How do I setup my CanCanCan permissions correctly?

I am a little confused about how to configure CanCanCan properly. For starters, do I have to add load_and_…

ruby-on-rails ruby-on-rails-4 cancan cancancan
Cancan accessible_by

What exactly is happening when I do: @patient.course_enrollments.accessible_by(current_ability) What seems to happen is I …

ruby-on-rails scope cancan
Rspec controller error expecting <"index"> but rendering with <"">

New to testing, I'm struggling to get some controller tests to pass. The following controller test throws the error: expecting &…

ruby-on-rails ruby-on-rails-3 rspec devise cancan
Getting Cancan's load_and_authorize_resource working within a custom create action

Trying to set up Cancan within an app of mine and having trouble with my PostsController. In a nutshell, when …

ruby-on-rails ruby-on-rails-3 cancan
CanCan and controllers without models

I'm using CanCan for authorization. I define the model-action-user rules in /app/config/ability.rb and it's working fine. I've …

ruby-on-rails cancan
Testing views that use CanCan and Devise with RSpec

I was trying to test a simple index view, which has following code inside: - if can? :destroy, MyModel %th …

ruby-on-rails ruby rspec devise cancan
CanCan - How to allow users to update and delete only their own objects

I've started a Rails application with Devise and CanCan. I have users which has a one-to-many relationship to articles. I'm …

ruby-on-rails authentication devise authorization cancan