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

Underscore in field name #12

Closed
d4rk5eed opened this issue Dec 26, 2014 · 7 comments
Closed

Underscore in field name #12

d4rk5eed opened this issue Dec 26, 2014 · 7 comments

Comments

@d4rk5eed
Copy link

What is the reason for using underscore in fieldname?

> Meeting.new.attributes
=> {"_id"=>BSON::ObjectId('549d746563616c2168060000'), "_meeting_quality"=>:hd, "_status"=>:inactive}

Actually we get another attribute that differ one we created

@xpepermint
Copy link

Asking the same question! Btw... I think that enum options should be strings (e.g. enum status: ["pending", "ready"] ).
+1

@alexanderk23
Copy link

+1

1 similar comment
@bhirsch42
Copy link

+1

@thetron
Copy link
Owner

thetron commented Feb 9, 2015

To be honest - I can't 100% remember my motivations for doing this. If I had to guess - it was probably to indicate that the field shouldn't be directly access, except through the getters and setters - following on from a few other (similar) gems that do similar things.

@xpepermint What are your thoughts on strings vs. symbols? I felt like symbols would be a better choice here, given that the values are immutable, but curious to hear why you feel these should be strings.

@xpepermint
Copy link

@thetron Huh, I don't remember exactly why but I think I was looking at rails enum function which works on strings.

@nofxx
Copy link

nofxx commented Jul 19, 2015

There's 5+ forks only to remove the underscore. +1 for me hehe.

@thetron
Copy link
Owner

thetron commented Jul 22, 2015

Thanks everyone again for your feedback here. I've merged in #12, which added a configuration option to customise the prefix. At some point in the future we might switch the default to be an empty string, but I wanted to make it easy for existing and future users to continue using the gem on the path to v1.0.0, and support for mongoid 5.

🍰

Bartuz added a commit to Bartuz/mongoid-enum that referenced this issue Sep 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants