On Saturday, November 3, 2012 7:05:47 PM UTC+5:30, Fahim Patel wrote: > > > > On Saturday, November 3, 2012 7:00:23 PM UTC+5:30, Colin Law wrote: >> >> On 3 November 2012 12:40, Fahim Patel <[email protected]> wrote: >> > >> > >> > On Saturday, November 3, 2012 5:20:35 PM UTC+5:30, Colin Law wrote: >> >> >> >> On 3 November 2012 11:46, Fahim Patel <[email protected]> wrote: >> >> > >> >> > 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 ? >> >> >> >> Have a look at the Rails Guide on debugging, it will show you >> >> techniques that you can use to debug your code. >> >> >> >> Colin >> > >> > >> > Hi Colin, >> > >> > Thanks for reply. >> > I use pry. >> > I Debug the good , when i use binding.pry my index object select all >> records >> > >> > but when i remove binding.pry and start to create new record than same >> issue >> > i am facing. >> > >> > Last record is not coming >> >> Then use some of the other techniques of debugging - insert debug code >> to print information about what is going on in the console for >> example. Print @admins.count for example in the controller index >> action to try and tie down where the problem lies. The first thing to >> determine is whether it the view is not displaying the last record or >> whether @admins does not include all the records. >> >> Are you using the latest version of the database gem? What is it? >> Look in Gemfile.lock to find out. >> >> > I puts @admins.count it give me correct counting on controller and when i > pass the object > to index view same thing is happening . > I am using Postgres and as you say i will delete Gemfile.lock and run the > bundle. > > Hope for the best > >> Colin >> > Hi Colin, Still facing a problem. Table count giving me accurate counting ,
but @admins = AdminUser.all give me records till last restart server. I don't know why this all is happening ? > >> >> >> > >> > Thanks >> >> >> >> >> >> > 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 >> >> > >> >> > >> >> > >> >> > >> >> > >> >> > -- >> >> > 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 [email protected]. >> >> > To unsubscribe from this group, send email to >> >> > [email protected]. >> >> > To view this discussion on the web visit >> >> > https://groups.google.com/d/msg/rubyonrails-talk/-/-TdNVrabhvAJ. >> >> > For more options, visit https://groups.google.com/groups/opt_out. >> >> > >> >> > >> > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/VRCMipxl3iMJ. For more options, visit https://groups.google.com/groups/opt_out.

