Project

doodoo

0.0
No commit activity in last 3 years
No release in over 3 years
A set of tools to help with CanCan. Doodoo provides a module for use with Rails controllers that assists with authorisation, especially with nested routes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0
~> 2.14

Runtime

>= 3.2
 Project Readme

Doodoo

A set of tools to help with CanCan. Doodoo provides a module for use with Rails controllers that assists with authorisation, especially with nested routes.

Installation

Add this line to your application's Gemfile:

gem 'doodoo'

And then execute:

$ bundle

Or install it yourself as:

$ gem install doodoo

Usage

Add to ApplicationController:

include Doodoo::NestedLoadAndAuthorize

And then in controllers (For example a TasksController, nested under ProjectsController):

before_action do
  # load task nested under project, only if params[:project_id] exists:
  load_and_authorize_if_present :project do
    load_and_authorize :task
  end

  # enforce nested load:
  load_and_authorize :project do
    load_and_authorize :task
  end

  # and for a shallow route:
  load_and_authorize :task

  # load without authorisation:
  load_resource :task

  # only specific actions
  load_and_authorize :task, :only => [:show]

  # supply a condition in should_load_task? method (can use a proc here too)
  load_and_authorize :task, :if => :should_load_task?

  # specific id parameter for another action:
  load_and_authorize :task, :id_param => :task_id, :only => [:other_action]

  # only load if parameter present in menu:
end

Contributing

  1. Fork it ( http://github.com//doodoo/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request