Please help...passing arrays between controller and view

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 = Account.new
@relations = []
3.times do
@rs << AccountEmployeeRelation.new
end
end

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 %>

<% for r in @relations %>
Employee:
<%= 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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs