lwe/simple_enum — pull request #54 by petedmarsh (2013-11-25 16:34:45+00:00)
Title: Change `validates_as_enum` to allow symbol values for string enums

Imagine we have the following model:

```
class User < ActiveRecord::Base
as_eum :status, [:deleted, :active, :dsiabled], :strings => true
validates_as_enum :status
end
```

If you use `User.find_or_create_by` you must use the underlying column name (`status_cd` by default in this case). This means that `status_cd` gets set directly, and not through `status=` so if you pass a symbol it does not get coerced to a string. ActiveRecord can do this coercion, but `validates_as_enum` expects the value of `status_cd` to be a string (one of `['deleted', 'active', 'disabled'] in this case).

So, this happens:

```
User.find_or_create_by(status_cd: :active) #=> ActiveRecord::RecordInvalid
User.find_or_create_by(status_cd: 'active') #=> #
```

This changes the validator to allow the column value to be a symbol iff the `strings` option is being used, which means you can do:

```
User.find_or_create_by(status_cd: :active) #=> #
```