lucascaton/enumerate_it

I'm getting null values when setting the value of an enumeration on an activerecord

dgdosen opened this issue · 2 comments

For example, in your notes, If I try to set the relationship_status on a person - I can in the console - but when I try to save it, the database still sets the value with null.

Can you add guidance as to what the data type the underlying association should be? (for different database vendors) - I'm assuming the associated types should be integer - but I can't get the enumerated type to save.

Is there a sample somewhere I should be able to see that at? and show us the migration for the underlying object (for example, for the Person class in your sample)

Thanks in advance.
--Dan

What database are you using? The work of converting the Ruby datatypes (strings or integers) to database types should be done my the Ruby dabatase adapter, it's never done by EnumerateIt, since it can even be used in non-ActiveRecord classes.

A simple example would be https://gist.github.com/821793

Please note that EnumerateIt does no work at all for recording and/or retrieving values from your database, this is all done by your ORM of choice. You can even use EnumerateIt with DataMapper, MongoDB or whatever tool that fits your needs.

that was a noob problem on my part - in my app I added

attr_accessor :type

to my model class, and the data wasn't getting saved. At the time, I didn't know that command would leave that attribute out of the db.