Rick Schumeyer
2007-Feb-16  15:13 UTC
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 %><br/>
<% for r in @relations %>
Employee:
<%= select_tag( r.employee,
   options_from_collection_for_select(Employee.find(:all, :order => 
''name''),''id'', ''name''))
%>
<br/>                                  
<% end %>
<%= submit_tag %>
<% end %>
If I get this working, I may still need help with the create controller.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
