I've now tried to get this working with a regular table as well, but
had no luck. It does work with the collection tag though...



On Jul 22, 4:09 pm, Iain <[email protected]> wrote:
> I'm getting the same problem. Did you find a fix? I have a workaround,
> which is that instead of passing in a variable through my controller,
> I call a method in my model to retrieve the same objects. That's
> pretty bad from an MVC point of view, although perhaps it fits in with
> the "fat model, thin client" ethos? :-s
>
> On Jul 11, 5:05 am, Montgomery Kosma <[email protected]> wrote:
>
>
>
> > Ah.  Spoke to soon.  Using this.project_custodians, of course,
> > bypasses the controller code that uses named scopes to set
> > @project_custodians to the appropriate sort order fortable-plus.
>
> > So ... perhaps the better question is why, during the ajaxupdate,
> > does @project_custodians come up as nil?
>
> > On Jul 10, 3:00 pm, Montgomery Kosma <[email protected]> wrote:
>
> > > AHA!!!
>
> > > I do not know exactly why, but I discovered via judicious debugger
> > > usage that @project was no longer valid during the ajaxupdateof my
> > >table-plus.  However, "this" was the current project.  So, it now
> > > appears to be updating correctly, having changed the context line for
> > > mytable-plusfrom
>
> > >       <table-pluswith="&[email protected]_custodians" ...
> > > to
> > >       <table-pluswith="&this.project_custodians" ...
>
> > > Now, on to further testing.
>
> > > On Jul 10, 2:54 pm, Montgomery Kosma <[email protected]> wrote:
>
> > > > Seems this should not be so hard, but let me ask a simpler question:
>
> > > > In all the various hobo ajax examples, controller code typically says
> > > > something like this:
>
> > > >      this.attributes = params[:project] || {}
> > > >      hobo_ajax_response if request.xhr?
>
> > > > What is the purpose & function of the first of these two lines?
>
> > > > On Jul 9, 2:21 am, Montgomery Kosma <[email protected]> wrote:
>
> > > > > Trying a new, simpler approach to try to get my app working -- have to
> > > > > complete v1.0 asap, or cancel the project.  To dodge my formlet
> > > > > troubles, I created a new show_action to add and delete
> > > > > ProjectCustodian (join table) associations, including:
>
> > > > > 1. a form with custodian name autocompleter and submit button
> > > > > 2. atable-plus, wrapped in a part, showing total number and list of
> > > > > custodians
>
> > > > > Almost everything works.  But when addupdate="my-foo-part" to submit
> > > > > (to get the table and total toupdate) orupdate="total-custodians" to
> > > > > delete-button (just toupdatethe count) I get a nasty pop-up dialog
> > > > > showing a bunch of html and an error message.
>
> > > > > My only thought is maybe I need toupd...@project_custodians somehow?
>
> > > > > Here's the controller code:
>
> > > > > show_action :editcustodians do
> > > > >     @project = find_instance
> > > > >     order = parse_sort_param("custodian.name", "custodian.type",
> > > > > "custodian.last_name")
> > > > >     @project_custodians =
> > > > > @project.project_custodians.custodian_names_like(params
> > > > > [:search]).sort_custodians_by(order)
> > > > >     this.attributes = params[:project] || {}
> > > > >     hobo_ajax_response if request.xhr?
> > > > >   end
>
> > > > > And the dryml:
>
> > > > > <show-page>
> > > > >   <collection: replace>
> > > > >           <form with="&ProjectCustodian.new" reset-form refocus-form
> > > > >update="my-foo-part">
> > > > >               <% this.project_id = @project.id -%>
> > > > >               <name-one:custodian complete-target="&@project"
> > > > > completer="new_custodian_name" />
> > > > >               <submit label="Add Custodian" />
> > > > >           </form>
>
> > > > >     <div part="my-foo-part">
> > > > >       <table-pluswith="&@project_custodians" fields="custodian.name,
> > > > > custodian.custodian_type, custodian.last_name">
> > > > >         <prepend-header:>
> > > > >           <div part="total-custodians">
> > > > >           <p class="subform-count">There <count prefix="are"/><%= "
> > > > > matching *#{params[:search]}*" unless params[:search].blank? %> </p>
> > > > >           </div>
> > > > >         </prepend-header:>
> > > > >         <empty-message:>No custodians have been added to this
> > > > > project.</empty-message:>
> > > > >         <controls:>
> > > > >           <delete-button class="ui-icon ui-icon-circle-close"
> > > > >update="total-custodians"/>
> > > > >         </controls:>
> > > > >       </table-plus>
> > > > >     </div>
> > > > >   </collection:>
> > > > > </show-page>
>
> > > > > And the error from the log after hitting delete:
>
> > > > > NoMethodError (You have a nil object when you didn't expect it!
> > > > > You might have expected an instance of Array.
> > > > > The error occurred while evaluating nil.split):
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/dryml/part_context.rb:112:in
> > > > > `parse_this_id'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/dryml/part_context.rb:90:in
> > > > > `unmarshal'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/dryml/part_context.rb:49:in
> > > > > `for_refresh'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/dryml/part_context.rb:55:in
> > > > > `initialize'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/dryml/part_context.rb:48:in `new'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/dryml/part_context.rb:48:in
> > > > > `for_refresh'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/dryml/template_environment.rb:
> > > > > 166:in `refresh_part'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/controller.rb:90:in
> > > > > `ajax_update_response'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/controller.rb:85:in `each'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/controller.rb:85:in
> > > > > `ajax_update_response'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:758:in
> > > > > `render'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/controller.rb:83:in
> > > > > `ajax_update_response'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/controller.rb:71:in
> > > > > `hobo_ajax_response'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:613:in
> > > > > `destroy_response'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:611:in
> > > > > `destroy_response'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:605:in
> > > > > `hobo_destroy'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/model_controller.rb:157:in
> > > > > `destroy'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/controller.rb:22:in `call'
> > > > >   vendor/plugins/hobo/hobo/lib/hobo/controller.rb:22:in
> > > > > `included_in_class'
>
> > > > > Rendered rescues/_trace (240.0ms)
> > > > > Rendered rescues/_request_and_response (5.0ms)
> > > > > Rendering rescues/layout (internal_server_error)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to