I have a table-plus displaying the rows of a table.  I'd like to put a
button on each row that posts an ajax request to update a few fields
in the row, then redisplay it.  It sounds easy but I just can't get it to work.



Here's my first attempt:

  <page title="Signups">
    <content:>
      <section class="content-body">
        <table-plus fields="this, first_name, last_name">
          <empty-message:>No signups match your criteria</empty-message:>
          <controls:>
            <div part="part-#{this.id}">
              <update-button label="Activate"
                params="&{:first_name=>'heidy'}" update="self"/>
            </div>
          </controls:>
        </table-plus>
      </section>
    </content:>
  </page>

This fails to render.  Dryml complains:

    invalid part="part#{this.id}" attribute on <div>

Any idea how I can render 45 different parts, one for each row?



So I tried updating the entire table instead:

  <page title="Signups">
    <content:>
      <section class="content-body">
        <table-plus fields="this, first_name, last_name" part="signups-table">
          <empty-message:>No signups match your criteria</empty-message:>
          <controls:>
            <div part="part-#{this.id}">
              <update-button label="Activate"
                params="&{:first_name=>'heidy'}" update="signups-table"/>
            </div>
          </controls:>
        </table-plus>
      </section>
    </content:>
  </page>

This renders, and when I click the button, the action does happen.
However, when Hobo tries to render the response, it throws:

  NoMethodError in SignupsController#update
  undefined method `member_class' for <Signup:0xb1f7a380>
  /vendor/rails/activerecord/lib/active_record/attribute_methods.rb:260:in
`method_missing_without_find_for'
  /vendor/plugins/hobo/hobo/lib/hobo/find_for.rb:48:in `method_missing'
  vendor/plugins/hobo/hobo/taglibs/rapid_plus.dryml:10:in `table_plus'
  /vendor/plugins/hobo/hobo/lib/hobo/dryml/template_environment.rb:328:in
`_tag_context'
  /vendor/plugins/hobo/hobo/lib/hobo/dryml/template_environment.rb:248:in
`new_context'


Any ideas on what I can try next?  I'd really like to get this working.

    - Scott



P.S.

On the second attempt, maybe Hobo is trying to render the entire table,
except it's only setting the context to the record that was used to render
the one row?  The parameters would indicate this:

  {"page_path"=>"signups/index", "render"=>{"0"=>{
     "id"=>"signups-table",
     "part_context"=>"BAhbCDoS...--050f09e43...\n"}},
   "signup"=>"",
   "id"=>"16",
   "first_name"=>"heidy"}


I tried resetting the context to the full table, with="&this_parent":

  <update-button with="&this_parent" label="Activate"
    params="&{:first_name=>'froufrou'}" update="signups-table"/>

But this fails during render:

  undefined method `reverse_reflection' for NilClass:Class
  vendor/plugins/hobo/hobo/lib/hobo/hobo_helper.rb:64:in `object_url'
  vendor/plugins/hobo/hobo/taglibs/rapid_forms.dryml:482:in `update_button'
  vendor/plugins/hobo/hobo/lib/hobo/dryml/template_environment.rb:326:in
`_tag_context'
  vendor/plugins/hobo/hobo/lib/hobo/dryml/template_environment.rb:267:in
`new_object_context'




Model and controller are totally straightforward:

  class Signup < ActiveRecord::Base
   hobo_model # Don't put anything above this

   fields do
     first_name :string
     last_name :string
   end

   def create_permitted?; true; end
   def update_permitted?; true; end
   def destroy_permitted?; true; end
   def view_permitted?(field); true; end
  end


  class SignupsController < ApplicationController
    hobo_model_controller
    auto_actions :all
  end

--~--~---------~--~----~------------~-------~--~----~
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