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