Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongoid and using where #116

Closed
Bartuz opened this issue Sep 30, 2015 · 2 comments
Closed

Mongoid and using where #116

Bartuz opened this issue Sep 30, 2015 · 2 comments

Comments

@Bartuz
Copy link

Bartuz commented Sep 30, 2015

Using mongoid I can't find objects with via enums.

Post.create(status: pending)
=> #<Calculation _id: 560c51a3cdea875eb5000000, status_cd: 0>
Post.where(status: :pending).count
=> 0
Post.where(status_cd: 0).count
=> 1
@Bartuz
Copy link
Author

Bartuz commented Sep 30, 2015

I started using different gem. works there. thetron/mongoid-enum#25

@lwe
Copy link
Owner

lwe commented Oct 1, 2015

Yes, there are named scopes es exposed like: Post.pendings for that, if you need to use the where clause, you can do something like

Post.where(status_cd: Post.status[:pending])

However we are planning a with_enum method or something similar, where it's possible to write with_enum(status: :pending) directly, see the thread in #95.

@lwe lwe closed this as completed Oct 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants