Re: [Rails] Re: Creating a new record doesnt update the browser view
On 5 July 2012 18:32, cyber c. <lists@ruby-forum.com> wrote:
>>> 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.
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
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home