Ruby on Rails
Friday, July 6, 2012
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
Clint Laskowski, CISSP, CISM
email: clint.laskowski@gmail.com
blog: http://www.tek414.com << new!
project: http://Signup.StartupWeekendMilwaukee.org << sign up
twitter: @Clint326
On Fri, Jul 6, 2012 at 8:37 AM, Rick <richard.t.lloyd@gmail.com> wrote:
On Friday, July 6, 2012 4:07:11 AM UTC-4, Colin Law wrote:On 5 July 2012 23:29, cyber c. <lists@ruby-forum.com> wrote:
>>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.
RickColin--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/UoLaqlnKPecJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en-US.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment