Hi , i am facing problem while i am writing code e.g. People.find_by_id(params[:id]) comment.find_by_id(params[:id]) when this execute it will delete only one record from the database which it get first. It will keep other records same.Is there any alternative to delete all records based this method. i tried with people=People.find(:all, :conditions=>["id=?",params[:id]]) but result is same. please help......... -- 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-03 13:46 UTC
Re: Problem with destroying multiple records........
On Dec 3, 1:20 pm, Dharmdip Rathod <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi , > > i am facing problem while i am writing code > e.g. > > People.find_by_id(params[:id]) > comment.find_by_id(params[:id]) > > when this execute it will delete only one record from the database which > it get first. It will keep other records same.Is there any alternative > to delete all records based this method. > > i tried with people=People.find(:all, :conditions=>["id=?",params[:id]]) > but result is same. >This doesn''t really make sense to me. There is only one record for a given value of the id column (or rather rails assumes that id is your primary key) so what were you expecting? Fred> please help......... > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dharmdip Rathod
2008-Dec-04 04:00 UTC
Re: Problem with destroying multiple records........
Frederick Cheung wrote:> On Dec 3, 1:20�pm, Dharmdip Rathod <rails-mailing-l...@andreas-s.net> > wrote: >> to delete all records based this method. >> >> i tried with people=People.find(:all, :conditions=>["id=?",params[:id]]) >> but result is same. >> > This doesn''t really make sense to me. There is only one record for a > given value of the id column (or rather rails assumes that id is your > primary key) so what were you expecting? > > FredI want all records base on query which i have written in people=People.find(:all, :conditions=>["id=?",params[:id]]) i am getting only one record not all records ... -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Dec-04 09:02 UTC
Re: Problem with destroying multiple records........
On Dec 4, 4:00 am, Dharmdip Rathod <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On Dec 3, 1:20 pm, Dharmdip Rathod <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > >> to delete all records based this method. > > >> i tried with people=People.find(:all, :conditions=>["id=?",params[:id]]) > >> but result is same. > > > This doesn''t really make sense to me. There is only one record for a > > given value of the id column (or rather rails assumes that id is your > > primary key) so what were you expecting? > > > Fred > > I want all records base on query which i have written in > people=People.find(:all, :conditions=>["id=?",params[:id]]) > i am getting only one record not all records ...There is only ever one such record because the primary key is unique (by definition). Fred> -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dharmdip Rathod
2008-Dec-04 11:10 UTC
Re: Problem with destroying multiple records........
Frederick Cheung wrote:> On Dec 4, 4:00�am, Dharmdip Rathod <rails-mailing-l...@andreas-s.net> > wrote: >> > primary key) so what were you expecting? >> >> > Fred >> >> I want all records base on query which i have written in >> people=People.find(:all, :conditions=>["id=?",params[:id]]) >> i am getting only one record not all records ... > > There is only ever one such record because the primary key is unique > (by definition). > > Fredk -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Thu, Dec 4, 2008 at 6:00 AM, Dharmdip Rathod < rails-mailing-list@andreas-s.net> wrote:> > Frederick Cheung wrote: > > On Dec 3, 1:20�pm, Dharmdip Rathod <rails-mailing-l...@andreas-s.net> > > wrote: > >> to delete all records based this method. > >> > >> i tried with people=People.find(:all, :conditions=>["id=?",params[:id]]) > >> but result is same. > >> > > This doesn't really make sense to me. There is only one record for a > > given value of the id column (or rather rails assumes that id is your > > primary key) so what were you expecting? > > > > Fred > > I want all records base on query which i have written in > people=People.find(:all, :conditions=>["id=?",params[:id]]) > i am getting only one record not all records ...I think this is not the real query you are having. you just chose a wrong example Assuming what u really want is to semulate people=People.find(:all, :conditions=>["country_id=?",params[:country_id]]) where country_id is a foreign key to something else People.find_by_country_id(params[:country_id]) will retrieve only the first record matching the condition. you should use People.find_all_by_country_id(params[:country_id]) to get all matching results. hope it helps -- Mahmoud Said Software Developer blog.modsaid.com www.eSpace.com.eg --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dharmdip Rathod
2008-Dec-04 13:01 UTC
Re: Problem with destroying multiple records........
Thx, -- 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 -~----------~----~----~----~------~----~------~--~---