Hi.. I want to read ID of last entered data set from table, are there any possible ways to it? help Im stucked..... thankx --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
try Model.find(:last) On Thu, Oct 30, 2008 at 5:12 PM, xxmithila <xxmithilaxx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi.. > > I want to read ID of last entered data set from table, are there any > possible ways to it? > help Im stucked..... > thankx > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
or: User.find(:all, :order => ''id DESC'', :limit=>1) On Oct 30, 12:44 pm, "bala kishore pulicherla" <balumc...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> try > Model.find(:last) > > On Thu, Oct 30, 2008 at 5:12 PM, xxmithila <xxmithil...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi.. > > > I want to read ID of last entered data set from table, are there any > > possible ways to it? > > help Im stucked..... > > thankx--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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. xxmithila wrote:> Hi.. > > I want to read ID of last entered data set from table, are there any > possible ways to it? > help Im stucked..... > thankx-- 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 -~----------~----~----~----~------~----~------~--~---
thankx guys but still there is a problem User.find(:all, :order => ''id DESC'', :limit=>1) and Model.find(:last) both return "#" mark only. whats the reson? i want last index id --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ok then say lst_id = Model.find(:last).id puts lst_id.inspect hope ''ll get this as Model.find_last retunrns the entire last record On Thu, Oct 30, 2008 at 5:53 PM, mithila karunarathna <xxmithilaxx-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> thankx guys > but > still there is a problem > > User.find(:all, :order => ''id DESC'', :limit=>1) > > and > > Model.find(:last) > > both return "#" mark only. whats the reson? i want last index id > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thankx guys I got the answer.... WoW.... answer was Model.maximum("id") thank u again for ur help --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---