really it should be simple to add.  I haven't done it, but from what
I've seen it's a one line addition to the end of your controller
action.

from 
http://cookbook.hobocentral.net/manual/ajax#supporting_hobo_ajax_in_random_controller_actions

hobo_ajax_response if request.xhr?

On Sep 27, 11:00 am, tjg <[email protected]> wrote:
> Hmm. I have just realized that my model is incorrect and both document
> and parcel should be 'has_and_belongs_to_many' associations (since a
> document can have many parcels, and the same parcels might be
> referenced by many other documents). Nothing like a weekend to help
> see this.
>
> But, still lost a little in what the Hobo Ajax response should be from
> the document_controller's addparcel method, if anyone can shed any
> light on how to use hobo_ajax_response.
>
> Tim
>
> On Sep 27, 10:11 am, tjg <[email protected]> wrote:
>
> > Merci, François!
>
> > While your suggestion made some sense, it is the reverse situation I
> > need. I am viewing the parent document, and I need to add child
> > parcels to the document (and not pick the owner of the parcel) These
> > parcels are represented by property descriptions, which would include
> > "lot, block, plan" designators. (My simplification to start with uses
> > only Lots). There are 10 000 parcels in the database, and users must
> > ALREADY know the parcel designation in order to add it to the
> > document. The best example is you drafting a mortgage document for
> > which you already know the related property(ies).
>
> > So, I cannot present the user with a list of possible parcels. There
> > are too many, and that wouldn't be permitted anyway.
>
> > I found myself needing to call a non-REST controller method (i.e.
> > addparcel). I managed to get Hobo to find the method by including
> > "webmethod :addparcel" at the top of the controller. But, I was left
> > puzzled as to what/how to respond within the controller, given I just
> > needed to refresh the <table-plus> of parcels. While I found pure
> > Rails examples of what to do (using an .rjs template), I could not
> > determine what to do from a Hobo point of view. "hobo_ajax_response"
> > isn't well documented, and I recall a note to say that "webmethod"
> > might be removed one day.
>
> > What should I be trying to respond with after having located the
> > specified parcel and added to document.parcels?
>
> > Thanks,
> > Tim
>
> > On Sep 25, 4:24 pm, François Beausoleil
>
> > <[email protected]> wrote:
> > > Hi!
>
> > > You want to look into <name-one/> and using :accessible => true on the
> > > has_many.
>
> > > You might want to look at the agility 
> > > tutorial:http://cookbook.hobocentral.net/tutorials/agility#associations
>
> > > Hope that helps!
> > > François
>
> > > On 25 sep, 12:32, tjg <[email protected]> wrote:
>
> > > > Hi all;
>
> > > > I'm sure I'm not the first Hobo-er to try this, but I am looking for
> > > > guidance, since a number of hours have already ticked by and I am
> > > > going in circles. I am, by no means, proficient with Hobo (yet), and
> > > > certainly not with Ajax, but here's what I'm trying to pull off:
>
> > > > A document shows a table of related parcels. When viewing a document,
> > > > I want to seach for an existing parcel and add it the table of
> > > > parcels, without leaving the page (Ajax).
>
> > > > I have:
>
> > > > class Document < ActiveRecord::Base
> > > >    hobo_model
> > > >    fields do
> > > >         name    :string
> > > >    end
> > > >    has_many :parcels
> > > > end
>
> > > > class Parcels < ActiveRecord::Base
> > > >    hobo_model
> > > >    fields do
> > > >       lot        :string
> > > >       block   :string
> > > >    end
> > > >    belongs_to    :document
> > > > end
>
> > > > When viewing a document, I have a table-plus that lists all the
> > > > parcels related to the document:
>
> > > > <table-plus with="&[email protected]" part="parcels-table" 
> > > > fields="id,
> > > > lot">
> > > > </table-plus>
>
> > > > Under this, I have a form by which I would like to search for a parcel
> > > > by lot number, and (if the parcel exists) add the parcel to the
> > > > document:
>
> > > > <form action="addparcel" method="GET" update="parcels-table"
> > > > message="Searching...">
> > > >         Lot: <input id="parcel[lot]" type="text" 
> > > > name="parcel[lot]"></input>
> > > >         <submit label="Search"/>
> > > > </form>
>
> > > > My documents_controller.rb has the 'addparcel' action defined:
>
> > > >   def addparcel
> > > >         @document = Document.find(params[:document_id])
> > > >         @parcel = Parcel.find(params[:lot])
>
> > > >         #Relate the parcel to the document
> > > >         @document.parcels << @parcel unless @parcel.nil?
>
> > > >         #What do I need to do here to get the document.parcels table to
> > > > refresh?
> > > >         #Something like this?
>
> > > >         respond_to do |format|
> > > >             format.html
> > > >             format.js
> > > >         end
>
> > > >    end
>
> > > > Am I on the right track, here, given this is blatant hacking trying to
> > > > figure out which was is up?
>
> > > > For the life of me, I cannot get past Rails bailing with this error:
>
> > > > ActionController::UnknownAction (No action responded to 1-new-
> > > > document. Actions: access_denied, addparcel,
> > > > authenticated_user_from_cookie, authorized?, create,
> > > > create_auth_cookie, create_for_package, destroy, edit, ht,
> > > > login_from_cookie, login_required, model, new, new_for_package,
> > > > redirect_back_or_default, show, store_location, and update):
>
> > > > The action exists, but what is missing?
>
> > > > Many thanks in advance,
> > > > Tim

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