Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Documentation

  • Loading branch information...
commit 08584b353750df670ae7e9e870a14275bcd8e90a 1 parent f6883a6
Laurent Cobos authored March 01, 2012
2  MIT-LICENSE
... ...
@@ -1,4 +1,4 @@
1  
-Copyright 2012 YOURNAME
  1
+Copyright 2012 Laurent Cobos - 11Factory
2 2
 
3 3
 Permission is hereby granted, free of charge, to any person obtaining
4 4
 a copy of this software and associated documentation files (the
46  README.rdoc
Source Rendered
... ...
@@ -1,3 +1,45 @@
1  
-= ActiveadminCancan
  1
+= ActiveAdmin-Cancan
2 2
 
3  
-This project rocks and uses MIT-LICENSE.
  3
+ActiveAdmin-Cancan provides a smooth integration of the two gems ActiveAdmin[https://github.com/gregbell/active_admin] and Cancan[https://raw.github.com/ryanb/cancan].
  4
+
  5
+{<img src="https://secure.travis-ci.org/11factory/activeadmin-cancan.png" />}[http://travis-ci.org/11factory/activeadmin-cancan]
  6
+
  7
+== Getting Started
  8
+
  9
+Active Admin - Cancan is released as a Ruby Gem. The gem is to be installed within a Ruby
  10
+on Rails 3 application. To install, simply add the following to your Gemfile:
  11
+
  12
+  gem 'activeadmin-cancan'
  13
+
  14
+== Configure CanCan
  15
+
  16
+You just have two things todo
  17
+
  18
+=== 1. Create the CanCan ability class
  19
+
  20
+User permissions are defined in an +Ability+ class. CanCan includes a Rails 3 generator for creating this class.
  21
+
  22
+  rails g cancan:ability
  23
+
  24
+See CanCan page [https://github.com/ryanb/cancan/wiki/defining-abilities] for details.
  25
+
  26
+=== 2. Handle Unauthorized Access
  27
+
  28
+If the user authorization fails, a <tt>CanCan::AccessDenied</tt> exception will be raised. You can catch this and modify its behavior in the +ApplicationController+.
  29
+
  30
+  class ApplicationController < ActionController::Base
  31
+    rescue_from CanCan::AccessDenied do |exception|
  32
+      redirect_to root_url, :alert => exception.message
  33
+    end
  34
+  end
  35
+
  36
+See CanCan page [https://github.com/ryanb/cancan/wiki/exception-handling] for more information.
  37
+
  38
+=== How it works
  39
+
  40
+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.
  41
+
  42
+
  43
+== Copyright
  44
+
  45
+Copyright (c) 2012 Laurent Cobos, 11Factory. See LICENSE for details.
13  activeadmin-cancan.gemspec
... ...
@@ -1,17 +1,16 @@
1 1
 $:.push File.expand_path("../lib", __FILE__)
2 2
 
3  
-# Maintain your gem's version:
4 3
 require "activeadmin-cancan/version"
5 4
 
6 5
 # Describe your gem and declare its dependencies:
7 6
 Gem::Specification.new do |s|
8 7
   s.name        = "activeadmin-cancan"
9 8
   s.version     = ActiveadminCancan::VERSION
10  
-  s.authors     = ["TODO: Your name"]
11  
-  s.email       = ["TODO: Your email"]
12  
-  s.homepage    = "TODO"
13  
-  s.summary     = "TODO: Summary of ActiveadminCancan."
14  
-  s.description = "TODO: Description of ActiveadminCancan."
  9
+  s.authors     = ["Laurent Cobos"]
  10
+  s.email       = ["laurent@11factory.fr"]
  11
+  s.homepage    = "https://github.com/11factory"
  12
+  s.summary     = "Provides CanCan roles to ActiveAdmin"
  13
+  s.description = "Provides CanCan roles to ActiveAdmin"
15 14
 
16 15
   s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
17 16
   s.test_files = Dir["test/**/*"]
@@ -19,6 +18,4 @@ Gem::Specification.new do |s|
19 18
   s.add_dependency "rails", ">= 3.0"
20 19
   s.add_dependency "cancan", ">= 1.6.2"
21 20
   s.add_dependency "activeadmin", ">= 0.4.0"
22  
-
23  
-  s.add_development_dependency "sqlite3"
24 21
 end

0 notes on commit 08584b3

Please sign in to comment.
Something went wrong with that request. Please try again.