Skip to content

Instantly share code, notes, and snippets.

@dnagir
Created October 26, 2011 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnagir/1315515 to your computer and use it in GitHub Desktop.
Save dnagir/1315515 to your computer and use it in GitHub Desktop.
CanCan optional load_and_authorize_resource
class PostsController < InheritedResources::Base
belongs_to :blog, :optional => true # The controller can be nested (/blog/1/posts) or flat (/posts)
# How do make load_and_authorize_resource accept optional :blog?
load_and_authorize_resource :blog
load_and_authorize_resource :post, :through => :blog
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment