Bit of a conundrum, I''m trying to offer a user the opportunity to
update 3 drop down collection selects at once which is working fine my
only problem is I can''t seem to get the default value to display,
I''ve
tried using :selected but that doesn''t seem to be working, my code
looks like:
In the view:
<%@quals=Qual.find(:all)%>
<%for assigned in @degree.assigneds%>
<p><label
for="assigned_grade">Grade</label><br/>
<%=text_field ''assigned''+assigned.id.to_s,
''grade'',"value"
=>assigned.grade %></p>
<p><label
for="''assigned''+assigned.id.to_s">Qualification
ID</
label><br/>
<%=collection_select(''assigned''+assigned.id.to_s, :qual_id,
@quals,:id, :screen_qual,{},:selected=>assigned.qual_id)%><br />
<%end%>
In the controller
@degree.attributes = params[:degree]
@degree.assigneds.each { |assigned| assigned.attributes
params[''assigned''+assigned.id.to_s] }
if @degree.valid? && @degree.assigneds.all?(&:valid?)
@degree.save!
@degree.assigneds.each(&:save!)
redirect_to :action => ''show'', :id => @degree
else
render :action => ''edit''
end
if I change the first variable in the collection select from
''assigned''+assigned.id.to_s to just :assigned then it does
work but
then I can;t work out how to differentiate between the input from each
of the drop downs in the controller.
Any help would be much appreciated
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---