Update/Create causing page reload to different controller for embedded scaffold.

66 views
Skip to first unread message

anithri

unread,
Dec 27, 2011, 5:11:35 PM12/27/11
to actives...@googlegroups.com
A Project has_many revisions.  I'm in the process of updating and rewriting a rails 2.3 app to a rails 3.1 app.

Revisions is an embedded AS in the Project Edit form.  It displays correctly inline.  Opening Create or Update forms correctly gets them from the server.  But when I edit an existing entry, or I create a new entry in the revisions table that's part of that form, It does the appropriate create/update action and then reloads the whole page to the revisions controller.  

The embedded scaffolds work correctly in my original app, but are not working correctly in the new one, and I don't know why.  I have rails 3.1.3, ActiveScaffold 3.1.13, CanCan 1.6.7

the form html looks like
<form accept-charset="UTF-8" action="/revisions?eid=25e6fec8578a1585ca609cb9fd0c7564" class="as_form create" data-loading="true" data-remote="true" id="as_25e6fec8578a1585ca609cb9fd0c7564-create--form" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓"><input name="authenticity_token" type="hidden" value="6ciqb988kB6GlkGCvjBy6I4mrP8qoMf643PH+gMTzcw="></div>


For an edit, the server receives a request like...
Started PUT "/revisions/336?eid=25e6fec8578a1585ca609cb9fd0c7564" for 127.0.0.1 at 2011-12-27 14:44:21 -0700

Includes a standard(as far as I can tell) parameter set
[2011-12-27 14:44:21] INFO  ActionController::Base :   Parameters: {"utf8"=>"✓", "authenticity_token"=>"6ciqb988kB6GlkGCvjBy6I4mrP8qoMf643PH+gMTzcw=", "record"=>{"revision_date"=>"2011-12-22", "revised_amount"=>"100.0", "optional_amount"=>"10.0", "notes"=>"Test"}, "commit"=>"Update", "eid"=>"25e6fec8578a1585ca609cb9fd0c7564", "id"=>"336"}

Then reports (After the Active Record updates)
[2011-12-27 14:44:21] INFO  ActionController::Base : Redirected to http://0.0.0.0:3000/revisions?eid=25e6fec8578a1585ca609cb9fd0c7564

and
Started GET "/revisions?eid=25e6fec8578a1585ca609cb9fd0c7564" for 127.0.0.1 at 2011-12-27 14:44:22 -0700

So I think one of two things is happening.
1.  The Update form is not getting properly setup to do an all javascript submit/return cycle.
2.  The Create action is returning HTML instead of JSON or doing a redirect for some other reason.

But I don't know what to look for next to help troubleshoot this, and I have 6 more scaffolds to embed on this form.   I have tried a second scaffold (addendums) and have the same behavior for that one.

I've attached the revisions_controller file and the revision model.

I'm rendering the forms in HAML as
      = render active_scaffold: "revisions", constraints: {project_id: @project.id}


Thanks for any insights you might provide.
revisions_controller.rb
revision.rb

Nick Rogers

unread,
Jan 3, 2012, 9:41:35 AM1/3/12
to actives...@googlegroups.com
What browser are you using? I've experienced similar (unresolved) problems with IE9.

--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group.
To view this discussion on the web visit https://groups.google.com/d/msg/activescaffold/-/2nSznC42_bwJ.
To post to this group, send email to actives...@googlegroups.com.
To unsubscribe from this group, send email to activescaffol...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.

anithri

unread,
Jan 5, 2012, 4:18:44 PM1/5/12
to actives...@googlegroups.com
This was using Chrome on Ubuntu.  It hadn't occured to me that it might be the browser...  The Rails 2.3 site with Active Scaffold has a nearly identical setup (without HAML) and it works on there.  I think I'll try and swap it to an erb page for test as well, just to try and rule out HAML.

anithri

unread,
Jan 9, 2012, 4:33:03 PM1/9/12
to actives...@googlegroups.com
Ok I've done some more research, and I've narrowed down the problem.

I set up a simple page in erb, and without making any changes to how it's called or the controller/config involved, it worked perfectly.
I took one of them embedded AS, and moved it around on the page,  If I move the render call either above the form_for block or below it, it works as expected.

So the problem only appears when the render call happens within a form_for block (generic or custom, neither works).  This makes me think that it is a DOM selector problem.

The problem is, I'm a bit stuck now, and am unsure how to proceed.  The way I have it setup is a form, and spread through the form, in kind of work flow order, are the embedded scaffolds.  I would much rather leave it that way.  I also suspect the problem is in the jQuery files since the older Prototype files for this same site worked fine.

Any pointers to the right files/functions?


Reply all
Reply to author
Forward
0 new messages