pelle/oauth-plugin — Issue #91: Mongoid::Errors::InvalidCollection in OauthConsumersController#index
Author: mgodwin
Created: 2011-10-12 01:13:38+00:00
State: open

Using the latest version of mongoid and oauth-plugin on rails 3.1, and I'm getting this error

Mongoid::Errors::InvalidCollection in OauthConsumersController#index

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

Looking at the OAuthConsumersController, it seems like this is the problem

@consumer_tokens=ConsumerToken.all :conditions=>{:user_id=>current_user.id}

Well that makes sense, since consumer_tokens is an embedded document inside of user. Changing it to:

@consumer_tokens=current_user.consumer_tokens

Fixes the problem but there are other instances of this throughout the controller files. Does mongoid work for anyone? Did these files change at some point? I can't imagine you were ever able to query against embedded documents in mongoid?