Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion last saved record not retrieving .

Received: by 10.66.85.166 with SMTP id i6mr1541440paz.13.1351943245797;
        Sat, 03 Nov 2012 04:47:25 -0700 (PDT)
X-BeenThere: rubyonrails-talk@googlegroups.com
Received: by 10.68.190.100 with SMTP id gp4ls18369302pbc.9.gmail; Sat, 03 Nov
 2012 04:46:48 -0700 (PDT)
Received: by 10.68.253.129 with SMTP id aa1mr1196797pbd.17.1351943208729;
        Sat, 03 Nov 2012 04:46:48 -0700 (PDT)
Date: Sat, 3 Nov 2012 04:46:47 -0700 (PDT)
From: Fahim Patel <pafa...@gmail.com>
To: rubyonrails-talk@googlegroups.com
Message-Id: <aceefae6-5055-478a-94fe-bdca72c4b163@googlegroups.com>
Subject: last saved record not retrieving .
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_59_6478241.1351943207816"

------=_Part_59_6478241.1351943207816
Content-Type: multipart/alternative; 
	boundary="----=_Part_60_29989112.1351943207818"

------=_Part_60_29989112.1351943207818
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit


Hi all, 


from last 1 hour i am facing one problem.

I have written a code for creating  user and show them in index page after 
save.

Code is working perfectly but on index page i am getting all record till 
second last record saved, but i am not getting current  record which is 
saved.

But in database my last record is saved successful.


But when i restart the server , than on index page all record come with the 
last record .

I dont know why this all is happening ?
Code below


######## controller code
class AdminUsersController < ApplicationController
  def new
    @admin = AdminUser.new
  end

  def index
    @admins = AdminUser.all
  end

  def create
    @admin = AdminUser.new(params[:admin_user])
    if @admin.save

      redirect_to admin_users_path
    else
      render "new"
    end
  end
end

######## new view############
<%= form_for @admin do|f|%>

First Name
<%= f.text_field :first_name%>
<%= submit_tag"Create"%>
<% end %>
######## index view############
<%= @admins%>

##############model
nothing in model



Hope you all understand the problem .


Thanks 

Regards
Fahim Babar Patel






------=_Part_60_29989112.1351943207818
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<br><div>Hi all,&nbsp;</div><div><br></div><div><br></div><div>from last 1 =
hour i am facing one problem.</div><div><br></div><div>I have written a cod=
e for creating &nbsp;user and show them in index page after save.</div><div=
><br></div><div>Code is working perfectly but on index page i am getting al=
l record till second last record saved, but i am not getting current &nbsp;=
record which is saved.</div><div><br></div><div>But in database my last rec=
ord is saved successful.</div><div><br></div><div><br></div><div>But when i=
 restart the server , than on index page all record come with the last reco=
rd .</div><div><br></div><div>I dont know why this all is happening ?</div>=
<div>Code below</div><div><br></div><div><br></div><div>######## controller=
 code</div><div><div>class AdminUsersController &lt; ApplicationController<=
/div><div>&nbsp; def new</div><div>&nbsp; &nbsp; @admin =3D AdminUser.new</=
div><div>&nbsp; end</div><div><br></div><div>&nbsp; def index</div><div>&nb=
sp; &nbsp; @admins =3D AdminUser.all</div><div>&nbsp; end</div><div><br></d=
iv><div>&nbsp; def create</div><div>&nbsp; &nbsp; @admin =3D AdminUser.new(=
params[:admin_user])</div><div>&nbsp; &nbsp; if @admin.save</div><div><br><=
/div><div>&nbsp; &nbsp; &nbsp; redirect_to admin_users_path</div><div>&nbsp=
; &nbsp; else</div><div>&nbsp; &nbsp; &nbsp; render "new"</div><div>&nbsp; =
&nbsp; end</div><div>&nbsp; end</div><div>end</div></div><div><br></div><di=
v>######## new view############</div><div><div>&lt;%=3D form_for @admin do|=
f|%&gt;</div><div><br></div><div>First Name</div><div>&lt;%=3D f.text_field=
 :first_name%&gt;</div><div>&lt;%=3D submit_tag"Create"%&gt;</div><div>&lt;=
% end %&gt;</div></div><div>######## index view############<br></div><div><=
div>&lt;%=3D @admins%&gt;</div></div><div><br></div><div>##############mode=
l</div><div>nothing in model</div><div><br></div><div><br></div><div><br></=
div><div>Hope you all understand the problem .</div><div><br></div><div><br=
></div><div>Thanks&nbsp;</div><div><br></div><div>Regards</div><div>Fahim B=
abar Patel</div><div><br></div><div><br></div><div><br></div><div><br></div=
><div><br></div>
------=_Part_60_29989112.1351943207818--

------=_Part_59_6478241.1351943207816--