Forum: Ruby on Rails Populating/updating values from select multiple

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
CSN (Guest)
on 2005-12-11 21:36
(Received via mailing list)
I have an edit page that displays the main record, and
also values from one-to-many tables (displayed in
select multiple fields). What's the easiest way to
update these one-to-many values? Is there something
like '@record.table2.attributes=params[:table2]',
which will delete and save the table2 values when
@record.save is called? I'm also not sure what I
should name my select fields -
'name="record[table2]"', 'name="table2"', etc. That
reminds me, is it possible to generate the select
fields in the first place by simply connecting them to
@record.table2? I'm currently doing this:

<select name="table2" multiple size=10>
<%= options_for_select(Table3.find_all.collect {|t3| [
t3.name, t3.id ] }, @t2.collect{|t2| t2.t3_id} ) %>
</select>

table 3 is id|name
table 2 is record_id|table3_id

thanks for any help!
csn

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
This topic is locked and can not be replied to.