Sha256: 531335d9642c2e1edb26c252e8edc5cef18143a403bab98e60d27cc002f09247
Contents?: true
Size: 905 Bytes
Versions: 2
Compression:
Stored size: 905 Bytes
Contents
= CancanNamespace Namespace for cancan gem. == Install gem 'cancan_namespace' == Usage class Ability include CanCanNamespace::Ability def initialize(user, context = nil) @context = context ... if user.admin? can :manage, :all can :manage, :all, :context => :manage end end end === Controller Manage::BaseController < ApplicationController protected def current_ability @current_ability ||= ::Ability.new(current_user, :manage) end end class Manage::PostsController < Manage::BaseController before_filter :find_post, :only => [:edit, :update, :destroy] authorize_resource ... end === View <% if can? :edit, post, :context => :manage %> <%= link_to 'Edit', edit_manage_post_path(post) %> <% end %> Copyright (c) 2011 Aimbulance, released under the MIT license
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cancan_namespace-0.1.2 | README.rdoc |
cancan_namespace-0.1.1 | README.rdoc |