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 S…
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 S…
Ruchita S. wrote:
Regards,
Ruchita S…
Hi, what have you tried so far?
Cheers,
Mohit.
10/19/2007 | 3:56 PM.
Mohit S. wrote:
Ruchita S. wrote:
Regards,
Ruchita S…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:
Selection | Name |
---|---|
<%= check_box('id_'+i.to_s, 'checked', {}, product.title, '') %> | <%= product.title %> |
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
On 10/19/07, Ruchita S. [email protected] 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:
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/
Rick Denatale wrote:
On 10/19/07, Ruchita S. [email protected] 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:
#73 Complex Forms Part 1 - RailsCasts
#74 Complex Forms Part 2 - RailsCasts
#75 Complex Forms Part 3 - RailsCastsThey 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 DeNataleMy blog on Ruby
http://talklikeaduck.denhaven2.com/
Hi,
Thanks a lot. These tutorials are really very helpful.
-Ruchita
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs