Nested form for a has_one model that already exists

Here’s the gist of my problem: (using formtastic)

Models:

Person (has_one :color)
Color

So I have this database full of already populated Color entries via a
whole separate controller + views for creating Colors. When creating a
person, I want to be able to select a Color object without creating it.
So I’m not looking for something such as:

= semantic_form_for @person do |form|
= form.input :name
= semantic_fields_for :color do |c|
= c.input :hex
= form.actions :submit

This would create a Color model to be associated with a Person. I want
something more along the lines of this functionality:

= semantic_form_for @person do |form|
= form.input :name
= form.input :color, :as => :select, :collection => @colors

so that I can select a Color that is already in the database.

I know there is a more rails-way to do this rather than having a “color
code” attribute and then perform a query to locate a Color that has the
corresponding color code. Any suggestions are much appreciated!

Thanks!

  • Mac