Associations, render a boolean column from a different model.

19 views
Skip to first unread message

Steven Leiva

unread,
Jun 30, 2016, 1:46:38 PM6/30/16
to SimpleForm
Hello All, 

I have two models, an Individual and a Profile.

A Profile belongs_to an Individual.

An Individual has_one Profile.

I am rendering a form for a profile instance. In this same form, I'd like to render the "blacklisted" column of the profile's individual. "blacklisted" is a boolean value. 

This seems like it should be possible, but I am having a tough time figuring out the correct API usage. At the moment, I have this:

        = f.association :individual, label: "Blacklisted", as: :select, collection: ["Yes", "No"]
 
I have to provide an explicit collection, because otherwise I will be rendering all of the Individuals in the system. This makes me think that I am going down the wrong path and there is likely an easier way to do this. 

I appreciate any help!
Reply all
Reply to author
Forward
0 new messages