Hi, I am trying to delete multiple products by using check boxes.... but not able to do it. Can anyone tell me how to use checkboxes to delete multiple products on clicking of a button. Any help would be greatly appreciated. Regards, Ruchita Sharma. -- 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 -~----------~----~----~----~------~----~------~--~---
Ruchita Sharma wrote:> Hi, > > > I am trying to delete multiple products by using check boxes.... but not > able to do it. Can anyone tell me how to use checkboxes to delete > multiple products on clicking of a button. > > > Any help would be greatly appreciated. > > Regards, > Ruchita Sharma. >Hi, what have you tried so far? Cheers, Mohit. 10/19/2007 | 3:56 PM. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mohit Sindhwani wrote:> Ruchita Sharma wrote: >> Regards, >> Ruchita Sharma. >> > > Hi, what have you tried so far? > > Cheers, > Mohit. > 10/19/2007 | 3:56 PM.yeah I am putting my code here, I am not able to delete the product list from the database: view: <form action=''<%= url_for(:action => "deleteSelection") %>'' method=''POST''> <table border="1" cellspacing="2" cellpadding="2" width="30%"> <tr><th width="5%">Selection</th><th align="left" width="25%">Name</th></tr> <% i = 0 @products.each do |product| i = i + 1 %> <tr> <td><%= check_box(''id_''+i.to_s, ''checked'', {}, product.title, '''') %></td> <td><%= product.title %></td> </tr> <% end %> </table> <br/> <input type=''submit'' value=''DELETE SELECTION''/> </form> controller: def deleteSelection @products = Product.find :all i = 0 products = @products.clone products.each { |product| i = i + 1 if (params[''id_''+i.to_s] != nil) then checked = params[''id_''+i.to_s][''checked''] if (checked != nil && checked.length > 0) then if (product.title == checked) then render_text "ccc" # render_text product.title @products.delete(product) i = i-1 end end end } render_action ''list'' end -- 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 -~----------~----~----~----~------~----~------~--~---
On 10/19/07, Ruchita Sharma <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hi, > > > I am trying to delete multiple products by using check boxes.... but not > able to do it. Can anyone tell me how to use checkboxes to delete > multiple products on clicking of a button. > > > Any help would be greatly appreciated.The latest RailsCasts might be useful: http://railscasts.com/episodes/73 http://railscasts.com/episodes/74 http://railscasts.com/episodes/75 They are a series, showing how to do CRUD on multiple models from a single view. The last one covers editing and deletion, but you probably want to watch all three. He''s using links instead of checkboxes, but the same principles should apply. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.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 -~----------~----~----~----~------~----~------~--~---
Rick Denatale wrote:> On 10/19/07, Ruchita Sharma <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> Hi, >> >> >> I am trying to delete multiple products by using check boxes.... but not >> able to do it. Can anyone tell me how to use checkboxes to delete >> multiple products on clicking of a button. >> >> >> Any help would be greatly appreciated. > > The latest RailsCasts might be useful: > > http://railscasts.com/episodes/73 > http://railscasts.com/episodes/74 > http://railscasts.com/episodes/75 > > They are a series, showing how to do CRUD on multiple models from a > single view. The last one covers editing and deletion, but you > probably want to watch all three. > > He''s using links instead of checkboxes, but the same principles should > apply. > > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/Hi, Thanks a lot. These tutorials are really very helpful. -Ruchita -- 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 -~----------~----~----~----~------~----~------~--~---