Question

hopefully this isn't too complicated..

So I have a model with LOTS of attributes, which I've decided to store as indexes in the database which refer to an constant at the model:

class Profile < ActiveRecord::Base
   STATUS_CHOICES = %w( single relationship married divorced complicated open )
   etc...

In my form, I'm doing this right now:

= f.simple_fields_for :profile do |p|
  = dp.input :relationship_status, :required => true, :collection => Datingprofile::STATUS_CHOICES

This displays the collection very well, but of course, the value needs to be set from the index coming through from the model. How would I set the values on the collection to correspond to the correct index of the STATUS_CHOICES array?

Update: Going to re-architect this to make the enum-ed attribs actual AD objects

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top