Hi Jin,
Jin Lee wrote:
> I''m trying to create a dynamic set of text fields as follows:
> In the controller, I grab the contents of params[:notes]
> and loop through them.
I don''t think I''m understanding your question.
The params hash is created by the browser and passed to the server. In
Rails that means it''s received by an action in a controller.
If you want to create an array from the params hash, assuming from your
example that the keys to the hash are translatable to integers, you can do:
notes_array = Array.new
params[:notes].each {|key, value| notes_array[key] = value}
If, on the other hand, you want to pass an array to a view for Rails to use
in creating a new page, you''d create an instance variable of type Array
in
your controller and then reference it in the view (.rhtml) file. If by
"preserve order" you mean you need to render the text boxes visually
from
top to bottom by index, you''ll want to iterate through the array (e.g.,
@notes.each) in your view and render a partial for each element.
hth,
Bill
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---