Mongoid belongs_to select raises NoMethodError and always returns empty results #740

Closed
rgarner opened this Issue Nov 11, 2011 · 1 comment

2 participants

@rgarner

This pull request was ostensibly to fix the NoMethodError problem with Mongoid relations.

However, it's still raising NoMethodError with select fields in 2.0.2 (a Mongoid belongs_to in my case). if reflection.options should (I think) read if reflection.respond_to(:options) in each case. However, this just masks a further problem - on Mongoid, if you use .scoped(:conditions => nil) or .scoped(:conditions => {}), the query will always return no results, meaning a blank select box. Looks like we need to conditionally omit the scoped(:conditions => ...) hash.

The workaround - for undefined method 'options' for #<Mongoid::Relations::Metadata> is to supply the collection to the input explicitly, e.g. = input :category, :collection => Category.all

(pull request inbound shortly)

@rgarner rgarner added a commit to rgarner/formtastic that referenced this issue Nov 11, 2011
@rgarner rgarner Fix for #740 - Mongoid belongs_to select raises NoMethodError and alw…
…ays returns empty results
a09a6db
@rgarner rgarner referenced this issue Nov 11, 2011
Merged

Fix for #740 #741

@justinfrench

Merged in, with thanks.

@jcf jcf added a commit to jcf/formtastic that referenced this issue Jan 27, 2012
@rgarner rgarner Fix for #740 - Mongoid belongs_to select raises NoMethodError and alw…
…ays returns empty results
8a68cc2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment