Mongoid::Errors::InvalidCollection #319

devilcoders opened this Issue Mar 26, 2011 · 2 comments

2 participants


I got an error with cancan:

Mongoid::Errors::InvalidCollection in MusiciansController#edit

Access to the collection for Musician is not allowed since it is an embedded document, please access a collection from the root document.

How could I create ability for embedded document?


Are you doing load_and_authorize_resource? That does not have support for embedded documents so you'll have to handle the loading yourself. You may want to do the authorization yourself too:

def edit
  @musician = # fetch embedded musician
  authorize! :edit, @musician

Thanks, will use reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment