» Home » cancan » Page 1
Rails CanCan: Doesn't CanCan assume I can :read if I can :update?
by Janne Lammi in Programming Languages

This works for an authorize! call

can [:read,:update], brand

but CanCan::AccessDenied is thrown when the line in the Ability class is changed to:

can :update, brand

brand is not nil.

If I can :update something, shouldn't I automatically be able to :read it?

I just want to know if this is by design, o

CanCan uninitialized constant Ability::CanCan
by Ohad Barzilay in Programming Languages

Any idea what I could be doing wrong here? I know it's not very useful to say ability.can? :manage, all; however I'm just trying to get started with CanCan.

I do have the gem, and have run generate cancan:ability.


Error and Code:

uninitialized constant Ability::CanCan
Extracted source (around line #4):

2: <

CanCan - Access denied - Way to make CanCan Specify in the LOG Why?
by Vrki in Programming Languages

I'm working to implement CanCan. For some reason CanCan keeps giving me Access Denied when I try to get specific about model permissions. And I can't figure out why.

Is there a way to get CanCan to be specific, perhaps in the logs or in development about Why Access is denied? something like, No Read Ability to XXX Model.

That would be helpful for debugging.


can not use cancan
by Uppsala9496 in Programming Languages

I am following rails casts episode 192 for cancan (http://railscasts.com/episodes/192-authorization-with-cancan?autoplay=true).

I have ruby 1.9.3
and rails 3.2.3

My gem file has this content

group :test, :development do
gem 'rspec-rails', '~> 2.5'
group :test do
gem 'cucumber-rails', '1.0.6'# use this instead of the
TAGS : cancan

CanCan gem for MVC .NET
by Aaviel in Programming Languages

I am looking for NuGet package that provides similar functionality as the CanCan gem in rails ( https://github.com/ryanb/cancan ).

Does anyone know a plugin that provides a similar functionality? Or a simple way to implement this?


TAGS : CanCan

CanCan authorize by id
by nipj in Programming Languages

I have a many to many relationship in rails, a user has and belongs to many user_types and vice versa. Then user_type has many roles.

Example table for roles_fruits table:

role_id: 1, fruit_id: 6

Example for roles table:

id: 1, name: Bannana Worker

Example table for users:

id: 1, user_name: employee143


TAGS : CanCan authorize

Cancan condition
by Dariosky in Programming Languages

I'm using CanCan in a project to manage different role level on each entity for each project.
I'm doing this:

# encoding: utf-8
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
if user.is_admin == true
can :manage, :all
can :read, :al
TAGS : Cancan condition

Rspec for cancan
by sjwaste in Programming Languages

I am not sure where I'll write test cases for our app, if i am using cacncan.

This should be in model or controller section.

In my case:

a user can delete or not a object.
To handle this case I used cancan and I think this code should be in model not in controller and how do I test this using rspec.

Please provide me a better advise.

TAGS : Rspec cancan

ActiveAdmin and CanCan
by Vasiliy in Programming Languages

I'm utilizing roles within AdminUsers inside Active Admin and am using CanCan to define access across different resources.

It's working well with regards to limiiting access, but I'm running into trouble hiding menus based on role.

According to the ActiveAdmin docs, the following should work:

menu :if => proc{ can?(:manage, AdminUser) }

Cancan permission
by kema in Programming Languages

I have a rails app that is is using cancan permission and i am trying to block others users from editing another user's dashboard. This has worked for other models but not this one.


belongs_to :dashboard


has_many :profiles


before_filter :authenticate_u

Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .