Creating a new record doesnt update the browser view

Hi,

I have a rails app. upon creating a new record from the browser(although it is being created successfully) it doesnt show up in the browsers view. Connecting to the DB , i confirmed that the record is created. I should do a "Rake db:migrate" inorder to make the record appear on the browser's view. Do i have to run rake:db migrate everytime i create a new request?

No, of course not. You only need to run rake db:migrate when you have a new migration to run. It is impossible for someone here to know the answer to your problem when you have given so little data. Have a look at the rails guide on debugging to get ideas on how to debug your code so you can identify where the problem is arising and if you still cannot work out why the new record does not appear then ask again.

Have you worked right through a tutorial such as railstutorial.org? If so then when you added a new record to a table there did it appear in the view? If it did, but in your app it does not, then try to work out what the difference is between your code and similar code in the demo in the tutorial.

Colin

Hi Colin,

Thanks for the response . I have spent enough time debugging my rails app and found that the default code generated by the rails itself is buggy. I have created a new scaffold for the resource Trial. After creating a new entry, the index page of the resource shows up stale data. (I start creating a new record, i get a message record created successfully, only to see that the index page doesnt show up any record). I had put up print statement in the controller index and saw that the statement "@trails = Trial.all" returns nothing. But if i do a "rake db:migrate" (which i dont have to do) the updated data shows up.

Any help on this is greatly appreciated. Please let me know if you need any info.

Im using rails version 3.2.4 My class controller

Class TrialsController < ApplicationController   # GET /trials   # GET /trials.json   def index     @trials = Trial.all

    respond_to do |format|       format.html # index.html.erb       format.json { render :json => @trials }     end   end

  # GET /trials/1   # GET /trials/1.json   def show     @trial = Trial.find(params[:id])

    respond_to do |format|       format.html # show.html.erb       format.json { render :json => @trial }     end   end

  # GET /trials/new   # GET /trials/new.json   def new     @trial = Trial.new

    respond_to do |format|       format.html # new.html.erb       format.json { render :json => @trial }     end   end

  # GET /trials/1/edit   def edit     @trial = Trial.find(params[:id])   end

  # POST /trials   # POST /trials.json   def create     @trial = Trial.new(params[:trial])

    respond_to do |format|       if @trial.save         format.html { redirect_to @trial, :notice => 'Trial was successfully created.' }         format.json { render :json => @trial, :status => :created, :location => @trial }       else         format.html { render :action => "new" }         format.json { render :json => @trial.errors, :status => :unprocessable_entity }

      end     end   end

  # PUT /trials/1   # PUT /trials/1.json   def update     @trial = Trial.find(params[:id])

    respond_to do |format|       if @trial.update_attributes(params[:trial])         format.html { redirect_to @trial, :notice => 'Trial was successfully updated.' }         format.json { head :no_content }       else         format.html { render :action => "edit" }         format.json { render :json => @trial.errors, :status => :unprocessable_entity }       end     end   end

  # DELETE /trials/1   # DELETE /trials/1.json   def destroy     @trial = Trial.find(params[:id])     @trial.destroy

    respond_to do |format|       format.html { redirect_to trials_url }       format.json { head :no_content }     end   end end

Hi Colin,

Please remember to quote the previous post when replying, I have just had to look back at the previous email to find what I suggested last time. This is a mailing list not a forum, though you may be accessing it via a forum style interface.

Thanks for the response . I have spent enough time debugging my rails app and found that the default code generated by the rails itself is buggy. I have created a new scaffold for the resource Trial. After creating a new entry, the index page of the resource shows up stale data. (I start creating a new record, i get a message record created successfully, only to see that the index page doesnt show up any record). I had put up print statement in the controller index and saw that the statement "@trails = Trial.all" returns nothing.

Did you mean @trials rather then @trails?

But if i do a "rake db:migrate" (which i dont have to do) the updated data shows up.

Have a look in development.log to see if there are any clues there. If you can't see anything post the section of the log starting with the GET for trials/new, through the create and ending with the index request.

Colin

Hi Colin,

Please remember to quote the previous post when replying, I have just had to look back at the previous email to find what I suggested last time. This is a mailing list not a forum, though you may be accessing it via a forum style interface.

Thanks for the response . I have spent enough time debugging my rails app and found that the default code generated by the rails itself is buggy. I have created a new scaffold for the resource Trial. After creating a new entry, the index page of the resource shows up stale data. (I start creating a new record, i get a message record created successfully, only to see that the index page doesnt show up any record). I had put up print statement in the controller index and saw that the statement "@trails = Trial.all" returns nothing.

Did you mean @trials rather then @trails?

Yes I meant trials

But if i do a "rake db:migrate" (which i dont have to do) the updated data shows up.

Have a look in development.log to see if there are any clues there. If you can't see anything post the section of the log starting with the GET for trials/new, through the create and ending with the index request.

Colin

I looked at the development.log , but couldn't find any useful info. Here is the log for your reference

Started GET "/trials/new" for 127.0.0.1 at Thu Jul 05 10:26:03 -0700 2012 Processing by TrialsController#new as HTML   Rendered trials/_form.html.erb (19.9ms)   Rendered trials/new.html.erb within layouts/application (21.3ms) Completed 200 OK in 37ms (Views: 36.9ms | ActiveRecord: 0.0ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 10:26:03 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 10:26:03 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

Started POST "/trials" for 127.0.0.1 at Thu Jul 05 10:26:19 -0700 2012 Processing by TrialsController#create as HTML   Parameters: {"commit"=>"Create Trial", "trial"=>{"name"=>"ruby", "email"=>"ror@hotmail.com"}, "authenticity_token"=>"cDA9t9ShPJPyZAOQH8rlXS038tLGJGCE9nItrHrD8JA=", "utf8"=>"✓"}    (0.1ms) begin transaction   SQL (1.5ms) INSERT INTO "trials" ("created_at", "email", "name", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Thu, 05 Jul 2012 17:26:19 UTC +00:00], ["email", "ror@hotmail.com"], ["name", "ruby"], ["updated_at", Thu, 05 Jul 2012 17:26:19 UTC +00:00]]    (1.2ms) commit transaction Redirected to http://localhost:3001/trials/2 Completed 302 Found in 9ms (ActiveRecord: 2.8ms)

Started GET "/trials/2" for 127.0.0.1 at Thu Jul 05 10:26:19 -0700 2012 Processing by TrialsController#show as HTML   Parameters: {"id"=>"2"}   Trial Load (0.2ms) SELECT "trials".* FROM "trials" WHERE "trials"."id" = ? LIMIT 1 [["id", "2"]]   Rendered trials/show.html.erb within layouts/application (1.1ms) Completed 200 OK in 39ms (Views: 37.9ms | ActiveRecord: 0.2ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 10:26:19 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 10:26:19 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

Started GET "/trials" for 127.0.0.1 at Thu Jul 05 10:26:45 -0700 2012 Processing by TrialsController#index as HTML   Rendered trials/index.html.erb within layouts/application (1.2ms) Completed 200 OK in 8ms (Views: 7.6ms | ActiveRecord: 0.0ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 10:26:45 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 10:26:45 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

The last request "GET /trials" renders only the old records and not the new record that i have just created.

Please letme know if you understand what's happening in this case.

There should be some sql fetching the records for the index view. It seems it has not fetched the records at all. Can you post index.html.erb. Copy/Paste it obviously. If it is large then use pastebin.com or similar.

Colin

buggy.

Started POST "/trials" for 127.0.0.1 at Thu Jul 05 10:26:19 -0700 2012    (1.2ms) commit transaction Completed 200 OK in 39ms (Views: 37.9ms | ActiveRecord: 0.2ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 10:26:45 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

The last request "GET /trials" renders only the old records and not the new record that i have just created.

There should be some sql fetching the records for the index view. It seems it has not fetched the records at all. Can you post index.html.erb. Copy/Paste it obviously. If it is large then use pastebin.com or similar.

Index.html.erb :

<h1>Listing trials</h1>

<table>   <tr>     <th>Name</th>     <th>Email</th>     <th></th>     <th></th>     <th></th>   </tr>

<% @trials.each do |trial| %>   <tr>     <td><%= trial.name %></td>     <td><%= trial.email %></td>     <td><%= link_to 'Show', trial %></td>     <td><%= link_to 'Edit', edit_trial_path(trial) %></td>     <td><%= link_to 'Destroy', trial, :confirm => 'Are you sure?', :method => :delete %></td>   </tr> <% end %> </table>

<br />

<%= link_to 'New Trial', new_trial_path %>

buggy.

Started POST "/trials" for 127.0.0.1 at Thu Jul 05 10:26:19 -0700 2012    (1.2ms) commit transaction Completed 200 OK in 39ms (Views: 37.9ms | ActiveRecord: 0.2ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 10:26:45 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

The last request "GET /trials" renders only the old records and not the new record that i have just created.

There should be some sql fetching the records for the index view. It seems it has not fetched the records at all. Can you post index.html.erb. Copy/Paste it obviously. If it is large then use pastebin.com or similar.

Index.html.erb :

<h1>Listing trials</h1>

Change the above line to <h1>Listing trials: count = <%= trials.count %></h1>

<table>   <tr>     <th>Name</th>     <th>Email</th>     <th></th>     <th></th>     <th></th>   </tr>

<% @trials.each do |trial| %>   <tr>     <td><%= trial.name %></td>     <td><%= trial.email %></td>     <td><%= link_to 'Show', trial %></td>     <td><%= link_to 'Edit', edit_trial_path(trial) %></td>     <td><%= link_to 'Destroy', trial, :confirm => 'Are you sure?', :method => :delete %></td>   </tr> <% end %> </table>

<br />

<%= link_to 'New Trial', new_trial_path %>

Now run the app, bring up the index and note the count shown (what is it and how many records do you see), add a record and then show the index again. Does the count change? Post the log for that complete cycle.

If the test is still not showing the new records what happens if you restart the rails server and then show the index?

One further point, I find it surprising that the id of the new record is 2. After all this messing about adding records there should be lots there. How many are there?

Colin

Now run the app, bring up the index and note the count shown (what is it and how many records do you see), add a record and then show the index again. Does the count change? Post the log for that complete cycle.

The count shown is old , doesnt include the newly created one.

Started GET "/trials/new" for 127.0.0.1 at Thu Jul 05 15:22:17 -0700 2012 Processing by TrialsController#new as HTML   Rendered trials/_form.html.erb (43.9ms)   Rendered trials/new.html.erb within layouts/application (54.3ms) Completed 200 OK in 90ms (Views: 88.9ms | ActiveRecord: 0.0ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 15:22:17 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 15:22:17 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

Started POST "/trials" for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012 Processing by TrialsController#create as HTML   Parameters: {"commit"=>"Create Trial", "authenticity_token"=>"cDA9t9ShPJPyZAOQH8rlXS038tLGJGCE9nItrHrD8JA=", "trial"=>{"name"=>"python", "email"=>"me@gmail.com"}, "utf8"=>"✓"}   ^[[1m^[[35m (0.1ms)^[[0m begin transaction   ^[[1m^[[36mSQL (31.6ms)^[[0m ^[[1mINSERT INTO "trials" ("created_at", "email", "name", "updated_at") VALUES (?, ?, ?, ?)^[[0m [["created_at", Thu, 05 Jul 2012 22:22:41 UTC +00:00], ["email", "me@gmail.com"], ["name", "python"], ["up   ^[[1m^[[35m (1.2ms)^[[0m commit transaction Redirected to http://localhost:3001/trials/3 Completed 302 Found in 40ms (ActiveRecord: 32.9ms)

Started GET "/trials/3" for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012 Processing by TrialsController#show as HTML   Parameters: {"id"=>"3"}   ^[[1m^[[36mTrial Load (0.3ms)^[[0m ^[[1mSELECT "trials".* FROM "trials" WHERE "trials"."id" = ? LIMIT 1^[[0m [["id", "3"]]   Rendered trials/show.html.erb within layouts/application (2.6ms) Completed 200 OK in 29ms (Views: 25.7ms | ActiveRecord: 0.3ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

Started GET "/trials" for 127.0.0.1 at Thu Jul 05 15:22:43 -0700 2012 Processing by TrialsController#index as HTML   Rendered trials/index.html.erb within layouts/application (2.8ms) Completed 200 OK in 11ms (Views: 11.0ms | ActiveRecord: 0.0ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 15:22:43 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 15:22:43 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

Started GET "/trials" for 127.0.0.1 at Thu Jul 05 15:22:48 -0700 2012 Processing by TrialsController#index as HTML   Rendered trials/index.html.erb within layouts/application (3.4ms) Completed 200 OK in 15ms (Views: 14.6ms | ActiveRecord: 0.0ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 15:22:48 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 15:22:48 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

If the test is still not showing the new records what happens if you

restart the rails server and then show the index?

I see the newer count (expected) once i restart the server

log:

Started GET "/trials" for 127.0.0.1 at Thu Jul 05 15:27:08 -0700 2012 Connecting to database specified by database.yml Processing by TrialsController#index as HTML   Trial Load (0.1ms) SELECT "trials".* FROM "trials"   Rendered trials/index.html.erb within layouts/application (7.2ms) Completed 200 OK in 94ms (Views: 72.9ms | ActiveRecord: 1.3ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 15:27:08 -0700 2012 Served asset /trials.css - 304 Not Modified (2ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 15:27:08 -0700 2012 Served asset /trials.js - 304 Not Modified (2ms)

One further point, I find it surprising that the id of the new record

is 2. After all this messing about adding records there should be lots there. How many are there?

I started with a new table and hence there are very few records :slight_smile:

Now run the app, bring up the index and note the count shown (what is it and how many records do you see), add a record and then show the index again. Does the count change? Post the log for that complete cycle.

The count shown is old , doesnt include the newly created one.

Started GET "/trials/new" for 127.0.0.1 at Thu Jul 05 15:22:17 -0700 2012 Processing by TrialsController#new as HTML   Rendered trials/_form.html.erb (43.9ms)   Rendered trials/new.html.erb within layouts/application (54.3ms) Completed 200 OK in 90ms (Views: 88.9ms | ActiveRecord: 0.0ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 15:22:17 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 15:22:17 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

Started POST "/trials" for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012 Processing by TrialsController#create as HTML   Parameters: {"commit"=>"Create Trial", "authenticity_token"=>"cDA9t9ShPJPyZAOQH8rlXS038tLGJGCE9nItrHrD8JA=", "trial"=>{"name"=>"python", "email"=>"me@gmail.com"}, "utf8"=>"✓"}   ^[[1m^[[35m (0.1ms)^[[0m begin transaction   ^[[1m^[[36mSQL (31.6ms)^[[0m ^[[1mINSERT INTO "trials" ("created_at", "email", "name", "updated_at") VALUES (?, ?, ?, ?)^[[0m [["created_at", Thu, 05 Jul 2012 22:22:41 UTC +00:00], ["email", "me@gmail.com"], ["name", "python"], ["up   ^[[1m^[[35m (1.2ms)^[[0m commit transaction Redirected to http://localhost:3001/trials/3 Completed 302 Found in 40ms (ActiveRecord: 32.9ms)

Started GET "/trials/3" for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012 Processing by TrialsController#show as HTML   Parameters: {"id"=>"3"}   ^[[1m^[[36mTrial Load (0.3ms)^[[0m ^[[1mSELECT "trials".* FROM "trials" WHERE "trials"."id" = ? LIMIT 1^[[0m [["id", "3"]]   Rendered trials/show.html.erb within layouts/application (2.6ms) Completed 200 OK in 29ms (Views: 25.7ms | ActiveRecord: 0.3ms)

Started GET "/assets/trials.css?body=1" for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012 Served asset /trials.css - 304 Not Modified (0ms)

Started GET "/assets/trials.js?body=1" for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012 Served asset /trials.js - 304 Not Modified (0ms)

Started GET "/trials" for 127.0.0.1 at Thu Jul 05 15:22:43 -0700 2012 Processing by TrialsController#index as HTML   Rendered trials/index.html.erb within layouts/application (2.8ms) Completed 200 OK in 11ms (Views: 11.0ms | ActiveRecord: 0.0ms)

Once again note that there is no sql showing the trials being fetched

... I see the newer count (expected) once i restart the server

log:

Started GET "/trials" for 127.0.0.1 at Thu Jul 05 15:27:08 -0700 2012 Connecting to database specified by database.yml Processing by TrialsController#index as HTML   Trial Load (0.1ms) SELECT "trials".* FROM "trials"   Rendered trials/index.html.erb within layouts/application (7.2ms) Completed 200 OK in 94ms (Views: 72.9ms | ActiveRecord: 1.3ms)

Here we /do/ see the sql fetching the records. Very odd. There must be something going wrong with the caching. Have you changed anything in the the config directory other than database.yml and routes.rb? Specifically environment.rb or anything in config/environments? Are you including any gems that might be relevant?

Post database.yml and the result of gem list

Has anyone else seen this situation before?

Colin

Now run the app, bring up the index and note the count shown (what is

it and how many records do you see), add a record and then show the

index again. Does the count change? Post the log for that complete

cycle.

The count shown is old , doesnt include the newly created one.

Started GET “/trials/new” for 127.0.0.1 at Thu Jul 05 15:22:17 -0700

2012

Processing by TrialsController#new as HTML

Rendered trials/_form.html.erb (43.9ms)

Rendered trials/new.html.erb within layouts/application (54.3ms)

Completed 200 OK in 90ms (Views: 88.9ms | ActiveRecord: 0.0ms)

Started GET “/assets/trials.css?body=1” for 127.0.0.1 at Thu Jul 05

15:22:17 -0700 2012

Served asset /trials.css - 304 Not Modified (0ms)

Started GET “/assets/trials.js?body=1” for 127.0.0.1 at Thu Jul 05

15:22:17 -0700 2012

Served asset /trials.js - 304 Not Modified (0ms)

Started POST “/trials” for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012

Processing by TrialsController#create as HTML

Parameters: {“commit”=>“Create Trial”,

“authenticity_token”=>“cDA9t9ShPJPyZAOQH8rlXS038tLGJGCE9nItrHrD8JA=”,

“trial”=>{“name”=>“python”, “email”=>“me@gmail.com”}, “utf8”=>“✓”}

^[[1m^[[35m (0.1ms)^[[0m begin transaction

^[[1m^[[36mSQL (31.6ms)^[[0m ^[[1mINSERT INTO “trials” (“created_at”,

“email”, “name”, “updated_at”) VALUES (?, ?, ?, ?)^[[0m [[“created_at”,

Thu, 05 Jul 2012 22:22:41 UTC +00:00], [“email”, “me@gmail.com”],

[“name”, “python”], ["up

^[[1m^[[35m (1.2ms)^[[0m commit transaction

Redirected to http://localhost:3001/trials/3

Completed 302 Found in 40ms (ActiveRecord: 32.9ms)

Started GET “/trials/3” for 127.0.0.1 at Thu Jul 05 15:22:41 -0700 2012

Processing by TrialsController#show as HTML

Parameters: {“id”=>“3”}

^[[1m^[[36mTrial Load (0.3ms)^[[0m ^[[1mSELECT “trials”.* FROM

“trials” WHERE “trials”.“id” = ? LIMIT 1^[[0m [[“id”, “3”]]

Rendered trials/show.html.erb within layouts/application (2.6ms)

Completed 200 OK in 29ms (Views: 25.7ms | ActiveRecord: 0.3ms)

Started GET “/assets/trials.css?body=1” for 127.0.0.1 at Thu Jul 05

15:22:41 -0700 2012

Served asset /trials.css - 304 Not Modified (0ms)

Started GET “/assets/trials.js?body=1” for 127.0.0.1 at Thu Jul 05

15:22:41 -0700 2012

Served asset /trials.js - 304 Not Modified (0ms)

Started GET “/trials” for 127.0.0.1 at Thu Jul 05 15:22:43 -0700 2012

Processing by TrialsController#index as HTML

Rendered trials/index.html.erb within layouts/application (2.8ms)

Completed 200 OK in 11ms (Views: 11.0ms | ActiveRecord: 0.0ms)

Once again note that there is no sql showing the trials being fetched

I see the newer count (expected) once i restart the server

log:

Started GET “/trials” for 127.0.0.1 at Thu Jul 05 15:27:08 -0700 2012

Connecting to database specified by database.yml

Processing by TrialsController#index as HTML

Trial Load (0.1ms) SELECT “trials”.* FROM “trials”

Rendered trials/index.html.erb within layouts/application (7.2ms)

Completed 200 OK in 94ms (Views: 72.9ms | ActiveRecord: 1.3ms)

Here we /do/ see the sql fetching the records. Very odd. There must

be something going wrong with the caching. Have you changed anything

in the the config directory other than database.yml and routes.rb?

Specifically environment.rb or anything in config/environments? Are

you including any gems that might be relevant?

Post database.yml and the result of

gem list

Has anyone else seen this situation before?

If, after you create a new record in your database, you just use the browser’s back button (or delete) to go back in history to your original index you will not see the new data. To demonstrate this just use: 1> rails new demonstrate 2> cd demonstrate 3> rails scaffold User name:string 4> rake db:create 5> rake db:migrate 6> rails server Then in your browser go to localhost:3000/users and create a new user. Then just use the browser’s history to go back to the view of the (empty) index at localhost:3000/users - you’ll notice it’s still empty. If instead of the browser’s history you use the Back link provided on the page displayed after the successful creation of the new user, you’ll see the new entry displayed in the index. Also, if you start another browser (say Safari if you’re currently using Firefox) on your local system and point it at localhost:3000/users Safari will not track changes you make in Firefox even if you use the Bake link provided by rails and get your Firefox index refreshed.

Rick

I think you missed the “generate” or “g” command in line 3. Shouldn’t it read:

3> rails generate scaffold User name:string

Thanks.

– Clint Clint Laskowski, CISSP, CISM

email: clint.laskowski@gmail.com

blog: http://www.tek414.com << new!

project: http://Signup.StartupWeekendMilwaukee.org << sign up

twitter: @Clint326

Hi Colin,

Here we /do/ see the sql fetching the records. Very odd. There must be something going wrong with the caching. Have you changed anything in the the config directory other than database.yml and routes.rb? Specifically environment.rb or anything in config/environments? Are you including any gems that might be relevant?

No i havent changed anything here. Just to remove any local changes i might have made, i am posting data from a newly created rails app.

routes.rb FirstApp::Application.routes.draw do   resources :trials

  get "say/hello"

  get "say/goodbye"

end

Post database.yml and the result of

# SQLite version 3.x # gem install sqlite3

It is a bit suspicious that you have 3.2.6 of only some of these. I should have asked you to post Gemfile and Gemfile.lock too.

Colin

It is a bit suspicious that you have 3.2.6 of only some of these. I

should have asked you to post Gemfile and Gemfile.lock too.

Gemfile.lock

GEM   remote: https://rubygems.org/   specs:     actionmailer (3.2.4)       actionpack (= 3.2.4)       mail (~> 2.4.4)     actionpack (3.2.4)       activemodel (= 3.2.4)       activesupport (= 3.2.4)       builder (~> 3.0.0)       erubis (~> 2.7.0)       journey (~> 1.0.1)       rack (~> 1.4.0)       rack-cache (~> 1.2)       rack-test (~> 0.6.1)       sprockets (~> 2.1.3)     activemodel (3.2.4)       activesupport (= 3.2.4)       builder (~> 3.0.0)     activerecord (3.2.4)       activemodel (= 3.2.4)       activesupport (= 3.2.4)       arel (~> 3.0.2)       tzinfo (~> 0.3.29)     activeresource (3.2.4)       activemodel (= 3.2.4)       activesupport (= 3.2.4)     activesupport (3.2.4)       i18n (~> 0.6)       multi_json (~> 1.0)     arel (3.0.2)     builder (3.0.0)     coffee-rails (3.2.2)       coffee-script (>= 2.2.0)       railties (~> 3.2.0)     coffee-script (2.2.0)       coffee-script-source       execjs     coffee-script-source (1.3.3)     erubis (2.7.0)     execjs (1.4.0)       multi_json (~> 1.0)     hike (1.2.1)     i18n (0.6.0)     journey (1.0.3)     jquery-rails (2.0.2)       railties (>= 3.2.0, < 5.0)       thor (~> 0.14)     json (1.7.3)     mail (2.4.4)       i18n (>= 0.4.0)

      mime-types (~> 1.16)       treetop (~> 1.4.8)     mime-types (1.18)     multi_json (1.3.6)     polyglot (0.3.3)     rack (1.4.1)     rack-cache (1.2)       rack (>= 0.4)     rack-ssl (1.3.2)       rack     rack-test (0.6.1)       rack (>= 1.0)     rails (3.2.4)       actionmailer (= 3.2.4)       actionpack (= 3.2.4)       activerecord (= 3.2.4)       activeresource (= 3.2.4)       activesupport (= 3.2.4)       bundler (~> 1.0)       railties (= 3.2.4)     railties (3.2.4)       actionpack (= 3.2.4)       activesupport (= 3.2.4)       rack-ssl (~> 1.3.2)       rake (>= 0.8.7)       rdoc (~> 3.4)       thor (>= 0.14.6, < 2.0)     rake (0.9.2.2)     rdoc (3.12)       json (~> 1.4)     sass (3.1.19)     sass-rails (3.2.5)       railties (~> 3.2.0)       sass (>= 3.1.10)       tilt (~> 1.3)     sprockets (2.1.3)       hike (~> 1.2)       rack (~> 1.0)       tilt (~> 1.1, != 1.3.0)     sqlite3 (1.3.5)     thor (0.15.2)     tilt (1.3.3)     treetop (1.4.10)       polyglot       polyglot (>= 0.3.1)     tzinfo (0.3.33)     uglifier (1.2.4)       execjs (>= 0.3.0)       multi_json (>= 1.0.2)

PLATFORMS   ruby

DEPENDENCIES   coffee-rails (~> 3.2.1)   jquery-rails   json   rails (= 3.2.4)   sass-rails (~> 3.2.3)   sqlite3 (= 1.3.5)   uglifier (>= 1.0.3)

Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.4'

# Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' group :development do   gem 'sqlite3', '1.3.5' end

gem 'json'

# Gems used only for assets and not required # in production environments by default. group :assets do   gem 'sass-rails', '~> 3.2.3'   gem 'coffee-rails', '~> 3.2.1'

  # See GitHub - sstephenson/execjs: Run JavaScript code from Ruby for more supported runtimes   # gem 'therubyracer', :platform => :ruby

  gem 'uglifier', '>= 1.0.3' end

gem 'jquery-rails'

# To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON # gem 'jbuilder'

# Use unicorn as the app server # gem 'unicorn'

# Deploy with Capistrano # gem 'capistrano'

# To use debugger # gem 'ruby-debug'

Others have suggested that you might just be seeing caching in the browser as a result of using the back button in the browser, you presumably are not doing this, and have tried refreshing the page in the browser. Which browser are you using?

Otherwise I am stumped.

Colin

Hi,

I'm not using the back button , but refreshing the browser to see the updated list. I'm using Safari browser. Tried with a chrome too(from a windows machine, ofcourse my rails server is still running on my mac machine) and i see the same result.