I have a class Bar
that has a user-defined list of config keys and values, defined like this:
class Bar < ActiveRecord::Base
has_many :config_keys, :through => Foo
has_many :config_values
end
So the available config keys come from the Foo
class and the values for those come from the Bar
class.
I'm creating a form for this Bar class, and I need to loop over each of the fields in config_keys
using the name
property as the label, but the textbox should be for the value
of the config_values
What I'm seeing is that if I do
<% f.fields_for bar.config_keys do |builder| %> <%= builder.object.class.to_s %> <-- Outputs 'Array' (what?) <% end %>
I thought that f.fields_for
on a collection would do the looping for me.
Am I approaching this the right way? Feels like I'm really fighting the framework.