can anyone tell me how can i get the last id(primary key) of the table --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
i don''t know if i understand correctly what you want to do, but you could just type: YourObjectName.last On 30 Okt., 13:05, "Ishara Gunathilake" <jaimgunathil...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> can anyone tell me how can i get the last id(primary key) of the table--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
oh forgot to ask for id: YourObjectName.last.id On 30 Okt., 13:08, MaD <mayer.domi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i don''t know if i understand correctly what you want to do, but you > could just type: > YourObjectName.last > > On 30 Okt., 13:05, "Ishara Gunathilake" <jaimgunathil...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > can anyone tell me how can i get the last id(primary key) of the table--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Naga harish Kanegolla
2008-Oct-30 12:14 UTC
Re: get the id of the last record from a table
If you want only the id of the last entered data then try this, User.maximum(''id'') This will return the maximum id which will be anyways the last one. Ishara Gunathilake wrote:> can anyone tell me how can i get the last id(primary key) of the table-- 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 -~----------~----~----~----~------~----~------~--~---
thanx,i did it,it was success 2008/10/30 Naga harish Kanegolla <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>> > If you want only the id of the last entered data then try this, > User.maximum(''id'') > This will return the maximum id which will be anyways the last one. > > Ishara Gunathilake wrote: > > can anyone tell me how can i get the last id(primary key) of the table > > -- > 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 -~----------~----~----~----~------~----~------~--~---