Hi..
I want to read ID of last entered data set from table, are there any possible ways to it? help Im stucked..... thankx
Hi..
I want to read ID of last entered data set from table, are there any possible ways to it? help Im stucked..... thankx
try Model.find(:last)
or:
User.find(:all, :order => 'id DESC', :limit=>1)
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
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
Thankx guys I got the answer…
WoW…
answer was
Model.maximum(“id”)
thank u again for ur help