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…
voicechats—>table1
chatusers---->table2 foreign key of table2 refers table1’s primary
key…
def create
@chatuser = Chatuser.new(params[:chatuser])
if Voicechat.find(@chatuser.voicechat_id).password ==
@chatuser.password
if @chatuser.save
flash[:notice] = ‘Sign in Successfull…’
@chatuser_pages, @chatusers
=paginate(:chatusers, :conditions=>[“voicechat_id=?”,
@chatuser.voicechat_id],:per_page=>18)
redirect_to :action => ‘list’
else
render :action => ‘new’
end
else
flash[:notice]=‘Plz enter correct password.’
render :action => ‘new’
end
end
and here comes my list method…
def list
@chatuser_pages, @chatusers
=paginate(:chatusers, :conditions=>[“voicechat_id=?”,
@chatuser.voicechat_id],:per_page=>18)
end
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…