Hi, i am wondering how i could do the following: I want to display all records of a table with a checkbox in front of it and after i checked some of them i want to submit this form and the controller has to process the selected records. (changing the value of a status field) if someone could give me some pointers or maybe a code example, i would be very gratefull! thanks remco -- 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 -~----------~----~----~----~------~----~------~--~---
bruce.balmer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Aug-24 15:19 UTC
[Rails] Re: selecting rows with checkboxes and process them
I''m pressed for time thsi morning. If you own a copy of AgileWebDevelopment then look up [] and it will give you the answer. If you don''t own the book, I''d suggest you buy one if at all possible. It will save you tens of hours of misery. If that doesn''t work try a google search including [] as this is what you add to the model name to get what you want. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeremy Wells
2006-Aug-24 16:35 UTC
[Rails] Re: selecting rows with checkboxes and process them
hey, uh well just customize the list.rhtml view so that it loops through each record and writes out a checkbox for each one in the correct location with a unique name, something like "checkbox_1" where the 1 is the id of the current record. Then wrap the list in a form pointing to an action called "list_update" or something. Then in the action, loop through all the items in param saying: param.each do |key,value| if key =~ /^checkbox_([0-9]+)$/ @record.find($1) @record.status = "new status" @record.save end end Remco Hh wrote:> Hi, i am wondering how i could do the following: > > I want to display all records of a table with a checkbox in front of it > and after i checked some of them i want to submit this form and the > controller has to process the selected records. (changing the value of a > status field) > > if someone could give me some pointers or maybe a code example, i would > be very gratefull! > > thanks > > remco > > >-- *Jeremy Wells* Serval Systems Ltd. www.servalsystems.co.uk <http://www.servalsystems.co.uk> Tel: 01342 331940 Fax: 01342 331950 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Remco Hh
2006-Aug-24 19:25 UTC
[Rails] Re: selecting rows with checkboxes and process them
hi, thanks for the answer I searched the book, but all i can find is that [] is the declaration of an array and that i already knew :o) searching "[]" with google is not possible bruce.balmer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> I''m pressed for time thsi morning. If you own a copy of > AgileWebDevelopment then look up [] and it will give you the answer. If > you don''t own the book, I''d suggest you buy one if at all possible. It > will save you tens of hours of misery. > > If that doesn''t work try a google search including [] as this is what > you add to the model name to get what you want.-- 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 -~----------~----~----~----~------~----~------~--~---
Remco Hh
2006-Aug-24 19:26 UTC
[Rails] Re: selecting rows with checkboxes and process them
Thank you Jeremy, I get it :0) i am going to trie this Jeremy Wells wrote:> hey, uh well just customize the list.rhtml view so that it loops through > each record and writes out a checkbox for each one in the correct > location with a unique name, something like "checkbox_1" where the 1 is > the id of the current record. Then wrap the list in a form pointing to > an action called "list_update" or something. Then in the action, loop > through all the items in param saying: > > param.each do |key,value| > if key =~ /^checkbox_([0-9]+)$/ > @record.find($1) > @record.status = "new status" > @record.save > end > end > > Remco Hh wrote: >> thanks >> >> remco >> >> >> > > -- > > *Jeremy Wells* > Serval Systems Ltd. > > www.servalsystems.co.uk <http://www.servalsystems.co.uk> > Tel: 01342 331940 > Fax: 01342 331950-- 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 -~----------~----~----~----~------~----~------~--~---