> Hi all;
>
> Just passing along some information conveyed to me by Bryan Larsen.
>
> In my controller, I had overridden an #edit action as follows:
>
> def edit
> @document = Document.find_by_id(params[:id])
> ...
> end
>
> The trouble with this method of loading the object being edited (the document) is that it's not setting a critical, internal Hobo variable named "this". The consequence of this was that my edit.dryml page's use of the <delete-button> tag was creating an ajaxified "in-place" version of the button instead of the usual button that would take me off the page. I would click the Delete button to delete the record being edited and expected to be redirected to the model's index page (as would be the automatic action after the delete), but after deleting the object, my browser just sat there not knowing what to do next, entertaining me with the "Removing" spinner.
>
> It turns out that Hobo's internal code for the <delete-button> tag includes the following line:
>
> in_place = false if in_place.nil? && this == @this && request.method.downcase == "get"
>
> In my case, the "this == @this" comparison was failing because there had been no assignment to @this.
That's quite peculiar - calling 'this' (a function) should have loaded @this from @document (around line 787 in lib/hobo/controller/model.rb). Was the controller doing this named something out of the ordinary (ie, not 'DocumentsController')?
--Matt Jones
> I wish I could say 'yes' but the controller was named DocumentsController and based directly on ApplicationController. Nothing unusual.
>
Wow. Finally ran this down - the problem came down to the order of some statements in DRYML's call_render function. Everything *looked* OK, but the instance variable that was being set had *already* been copied into the TemplateEnvironment (as nil).
Thanks!
--Matt Jones
>
> Okay, does that mean that (after picking up your patch in Hobo), I should return to my original approach, as a matter of style? I have to admit that thinking in terms of setting "self.this" is a bit low-level for my liking when (really) all I'm thinking of doing is loading a document by id.
>
> Will your patch correctly set self.this now if do @document = Document.find_by_id(params[:id])?
Yep - the code was trying really hard to do it before, but the data wasn't making it into the template environment. It should work now.
--Matt Jones