Nested forms with select lists


I’d like to use a drop down select field to add multiple categories to
my model (has_many relationship) using nested forms in Rails 2.3.2. I
can get it to work fine with straight text fields, but no matter what
I do with select elements I always end up with “undefined method
`merge’ for #Array:0x2246420

Does anyone have a working example of using nested forms with select?

Thank you


Can you possibly post some sample code so that we can see how your
select lists are defined and how your controller is attaching the
categories to your object? It might be a fairly easy fix to point out.



Thanks. Somewhat edited, it basically looks like this.


class Cpicture < ActiveRecord::Base
belongs_to :historicsite
has_many :tags, :dependent => :destroy
accepts_nested_attributes_for :tags, :allow_destroy => true,
:reject_if => proc { |attrs| attrs.all? { |k, v|
v.blank? }}

VIEW: part of edit.html.erb
<% cpform.fields_for :tags do |tag_form| %>
<%=‘tag’, ‘tag_group’, [[“value_1”,“value1”],
[“value_2”,“value2”], [“value_3”,“value3”]]) %>
<%=‘tag’, ‘tag_name’, [[“value_1”,“value1”],
[“value_2”,“value2”], [“value_3”,“value3”]]) %>

<% unless tag_form.object.nil? || tag_form.object.new_record? %>
<%= tag_form.label ‘_delete’, ‘Remove:’ %>
<%= tag_form.check_box ‘_delete’ %>
<% end %>
<% end %>


def edit
@cpicture = Cpicture.find(params[:id])
2.times {}

def update
@cpicture = Cpicture.find(params[:id])
if @cpicture.update_attributes(params[:cpicture])
flash[:notice] = ‘Cpicture was successfully updated.’
redirect_to :action => ‘show’, :id => @cpicture
render :action => ‘edit’

On Jun 1, 1:53 pm, nodoubtarockstar removed_email_address@domain.invalid