electronick / enum_column

Enum column support for Rails 3
MIT License
75 stars 45 forks source link

switching to strings in enum limits #12

Open jsaedtler opened 12 years ago

jsaedtler commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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 commented 12 years ago

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.