Coder Social home page Coder Social logo

activeadmin-cancan's Introduction

ActiveAdmin-Cancan

ActiveAdmin-Cancan provides a smooth integration of the two gems ActiveAdmin and Cancan.

<img src=“https://secure.travis-ci.org/11factory/activeadmin-cancan.png” />

Getting Started

Active Admin - Cancan is released as a Ruby Gem. The gem is to be installed within a Ruby on Rails 3 application. To install, simply add the following to your Gemfile:

gem 'activeadmin-cancan'

Configure CanCan

You just have two things todo

1. Create the CanCan ability class

User permissions are defined in an Ability class. CanCan includes a Rails 3 generator for creating this class.

rails g cancan:ability

See CanCan page [github.com/ryanb/cancan/wiki/defining-abilities] for details.

2. Handle Unauthorized Access

If the user authorization fails, a CanCan::AccessDenied exception will be raised. You can catch this and modify its behavior in the ApplicationController.

class ApplicationController < ActionController::Base
  rescue_from CanCan::AccessDenied do |exception|
    redirect_to root_url, :alert => exception.message
  end

  def current_ability
    @current_ability ||= Ability.new(current_admin_user)
  end 
end

See CanCan page [github.com/ryanb/cancan/wiki/exception-handling] for more information.

How it works

I have just made the integration between the two gems, the two steps above are the only ones todo to get roles working with ActiveAdmin.

Copyright © 2012 Laurent Cobos, 11Factory. See LICENSE for details.

activeadmin-cancan's People

Contributors

shell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

activeadmin-cancan's Issues

immediately after bundle install

/gems/activeadmin-cancan-0.1.2/lib/activeadmin-cancan/authorization.rb:9:in register': undefined local variable or methodresource_dsl' for #ActiveAdmin::Namespace:0x007f8d41431888 (NameError)

Authorization Not Performed

I`ve installed the activeadmin gem and also this one and I'm getting this error:

CanCan::AuthorizationNotPerformed in Admin::DashboardController#index

This action failed the check_authorization because it does not authorize_resource. Add skip_authorization_check to bypass this check.

Not sure if it is working

Hi,

So far I have no errors on the logs...

The thing is that I have some abilities that allow a user with role 'leader' only read projects with an status of finished... But still the projects index page is listing all the projects, and if I click on the show page of a started project that leader user is still able of seeing the information.

Is this the correct behavior?

current activeadmin gem not working with cancan

if i install the activeadmin gem from the current github repo, then i get that errormessage

NoMethodError - protected method `authorize!' called for #Admin::UsersController:0xa4f301c:

if i go back to official 0.5.1 - working

dont know why.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.