Forum: Ruby on Rails Please help...passing arrays between controller and view

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
0c51049fb747cd60088e4878458e05d1?d=identicon&s=25 Rick Schumeyer (Guest)
on 2007-02-16 16:16
(Received via mailing list)
I have tried to get this question answered before with no success.  I'm
getting desperate!
Here is a simplified description of my problem...

I have a many-to-many relationship between accounts and employees, with
a model table in between called AccountEmployeeRelations.  There is
other stuff in this table, but I don't think that matters for now.

In the controller I create and account and 3 relations (I plan on
changing this after I get it working)

  def new
    @account =
    @relations = []
    3.times do
      @rs <<

I am really lost in new.rhtml.  I need selections for multiple
employees.  I'm not sure if this is even close, but I know it does not
work.  I think I need something like select_tag( r.employee[] ) but I
can't figure that part out.

<% form_for :account, :url => { :action => :create } do |form| %>
Title: <%= form.text_field :title %><br/>

<% for r in @relations %>
<%= select_tag( r.employee,
   options_from_collection_for_select(Employee.find(:all, :order =>
'name'),'id', 'name'))
<% end %>

<%= submit_tag %>
<% end %>

If I get this working, I may still need help with the create controller.
This topic is locked and can not be replied to.