i want to implement check box in the list of rows and i want to link the checked action to destroy.please kindly help me. -- 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 -~----------~----~----~----~------~----~------~--~---
Dilip Bv wrote:> i want to implement check box in the list of rows and i want to link the > checked action to destroy.please kindly help me.please be more specific. put it in context and show any code you have -- 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 -~----------~----~----~----~------~----~------~--~---
iam having a view of table which have contents and i want to add up a check box for each column how can i implement.please help me. -- 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 -~----------~----~----~----~------~----~------~--~---
There are probably better ways, but here''s how I would do it: Create a check box for every row, and assign it a name that''s based on the id of the record displayed, along the lines of: for item in @items <td><%= check_box ''delete_check_''+item.id.to_s %></td> For each checkbox that is checked, the form will return params[:delete_check_xxx] (xxx being the id number) So in your controller, check for the existence of params[:delete_check_xxx] while xxx < @items.length, for each one that''s found, find the item by the id and destroy it. On Nov 16, 2:52 pm, Dilip Bv <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> iam having a view of table which have contents and i want to add up a > check box for each column how can i implement.please help me. > > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Better would be something like:
<%= check_box_tag "delete_check[#{item.id}]", value = true %>
Then the params come into your method as a hash of results:
Parameters: {"action"=>"index",
"delete_check"=>{"23"=>"true",
"47"=>"true"},
"controller"=>"whatever"}
Then you can iterate over all the checked items:
params[:delete_check].each_key do |delete_id|
....
end
David Schmidt
zero halo wrote:> There are probably better ways, but here''s how I would do it:
>
> Create a check box for every row, and assign it a name that''s
based on
> the id of the record displayed, along the lines of:
>
> for item in @items
> <td><%= check_box ''delete_check_''+item.id.to_s
%></td>
>
> For each checkbox that is checked, the form will return
> params[:delete_check_xxx] (xxx being the id number) So in your
> controller, check for the existence of params[:delete_check_xxx] while
> xxx < @items.length, for each one that''s found, find the item
by the id
> and destroy it.
>
> On Nov 16, 2:52 pm, Dilip Bv
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
>
>> iam having a view of table which have contents and i want to add up a
>> check box for each column how can i implement.please help me.
>>
>> --
>> Posted viahttp://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
-~----------~----~----~----~------~----~------~--~---