How to get recently saved record

hi all…

im new to rails…im developin a app in which wen a record is created
through create method in controller class…my create method in
controller is shown below…

chatusers---->table2 foreign key of table2 refers table1’s primary

def create
@chatuser =[:chatuser])

if Voicechat.find(@chatuser.voicechat_id).password ==


flash[:notice] = ‘Sign in Successfull…’

@chatuser_pages, @chatusers
=paginate(:chatusers, :conditions=>[“voicechat_id=?”,

redirect_to :action => ‘list’
render :action => ‘new’
flash[:notice]=‘Plz enter correct password.’
render :action => ‘new’


and here comes my list method…

def list

@chatuser_pages, @chatusers
=paginate(:chatusers, :conditions=>[“voicechat_id=?”,


the problem is that @chatuser is local to create method… but i want
the foreign key of that record…so that i can use it in list
method…is there a way to get the recently saved record…so that i
can use that…plz anyone help me out…it would be great even if u
provide alternate solution…thanks in advance…

The create method I assume is from a user request, so it is a
different HTTP request from the list. The data from the create
method is long gone, and could even be in a different mongrel server.

If you want to highlight the last created record you will need to
store in each record the creation time and the creating user, then
compare those to the current user and highlight the newest record in
the list. There are standard column names for time stamps that will
be set by AR when a record is saved, but setting the user will need
to be done in a before_save filter or in your app logic.