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

switching to strings in enum limits #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jsaedtler
Copy link

I switched the type of the enums limit array contents from symbols to strings, as enums with values like "!" resulted in invalid symbols ( :! )
enums look now like this:

t.enum "action", :limit => ["-", "s", "i", "c", "!"]

@electronick
Copy link
Owner

It's king of really serious change, as the idea of gem is in using symbols, not strings (it's easier to find usages of symbols in project, for example, strings are not immutable, and so on). If you need to use strings like "!" you can also use them as symbols like :"!" or :"-", this is valid ruby syntax.
Please let me know if it works.

@jsaedtler
Copy link
Author

I've got a legacy database containing these enum columns with "!" values.
When i dump the schema via rake db:schema:dump, the enum gem generates these invalid symbols, so the schema.rb isn't valid.
You think it's better to always generate :"[enum_value]" kind of values?

@electronick
Copy link
Owner

It's not necessary to do it always, but if string value contains special symbols (regexp is something like /^\w/) it's better to do it, I deem.

@electronick electronick reopened this Mar 15, 2012
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

Successfully merging this pull request may close these issues.

2 participants