hey guys, I''ve searched around and haven''t been able to turn up much. Here is the gist of what I need to accomplish. I need to be able to pass a view generated array to a controller for processing. Basically a varying amount of ids... sometimes 1 sometimes 10. Has anyone every done something similar? I will be glad to divulge my details if this is to vague. Thanks, Ken --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You name the elements with []''s like this: <%= check_box_tag "colors[red]", 1, false, :id => ''colors_red'' -%> <%= check_box_tag "colors[blue]", 1, false, :id => ''colors_blue'' -%> <%= check_box_tag "colors[green]", 1, false, :id => ''colors_green'' -%> Then in your controller, checked boxes will be available as: params[:colors][:red], parmas[:colors][:blue], etc predhme wrote:> hey guys, > > I''ve searched around and haven''t been able to turn up much. Here is > the gist of what I need to accomplish. I need to be able to pass a > view generated array to a controller for processing. Basically a > varying amount of ids... sometimes 1 sometimes 10. > > Has anyone every done something similar? I will be glad to divulge my > details if this is to vague. > > Thanks, > > Ken > > > > >-- Sincerely, William Pratt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks, your response helped... basically i used a <%= text_field "item" "first_item" %> <%= text_field "item" "second_item" %> for whatever reason it wouldn''t allow me to do a item[first] for the name as you suggested. it claimed that @item[] cannot be used for an instance variable name. but i have it working now. thanks again. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If you want to do it the way I showed, you need to use text_field_tag not text_field. text_field and the other _field helpers are designed to be used with a specific object where there _tag brothers are designed to generate tags not based on a specific object. predhme wrote:> thanks, your response helped... > > basically i used a > > <%= text_field "item" "first_item" %> > <%= text_field "item" "second_item" %> > > for whatever reason it wouldn''t allow me to do a item[first] for the > name as you suggested. it claimed that @item[] cannot be used for an > instance variable name. but i have it working now. thanks again. > > > > > >-- Sincerely, William Pratt --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Interesting. I will have to play around with that. Thanks much. On Sep 28, 3:07 pm, William Pratt <bi...-YbheRAKfYF4eIZ0/mPfg9Q@public.gmane.org> wrote:> If you want to do it the way I showed, you need to use text_field_tag > not text_field. text_field and the other _field helpers are designed to > be used with a specific object where there _tag brothers are designed to > generate tags not based on a specific object. > > > > predhme wrote: > > thanks, your response helped... > > > basically i used a > > > <%= text_field "item" "first_item" %> > > <%= text_field "item" "second_item" %> > > > for whatever reason it wouldn''t allow me to do a item[first] for the > > name as you suggested. it claimed that @item[] cannot be used for an > > instance variable name. but i have it working now. thanks again. > > -- > Sincerely, > > William Pratt--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
predhme wrote:> hey guys, > > I''ve searched around and haven''t been able to turn up much. Here is > the gist of what I need to accomplish. I need to be able to pass a > view generated array to a controller for processing. Basically a > varying amount of ids... sometimes 1 sometimes 10. > > Has anyone every done something similar? I will be glad to divulge my > details if this is to vague.The :index option for form helpers might be useful. http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html -- Josh Susser http://blog.hasmanythrough.com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---