Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Cancan 2.0 fix for issue #565; fixes namespaced non-db/model backed resources authorization #570
Here's something interesting Ryan. I've returned working on an old app and until now I was treating its resource as a non-db backed resource; hence the patch above. However, now I'm doing CRUD as well.
class Admin::ScheduledSessionsController < AdminController include ApplicationHelper load_and_authorize_resource :class => "Session"
...and my abilities now look like:
class AdminAbility include CanCan::Ability def initialize(user) if user can [:index, :show], "admin/dashboard" can [:index, :show, :published, :unpublished], "admin/scheduled_sessions" if user.super_admin? can [:new, :create], "admin/scheduled_sessions" can [:new, :create], :sessions can [:edit, :update], "admin/scheduled_sessions" can [:edit, :update], :sessions do |s| s.applicant_signups.count == 0 end can [:publish, :unpublish], "admin/scheduled_sessions" can [:publish, :unpublish], :sessions end end end end