Have you seen this recipe?
http://cookbook.hobocentral.net/recipes/33-ajax-filtering-on-a-partially-completed
I think that's fairly close to what you're looking for. \
Bryan
tomPorter wrote:
A more concrete example:
I have a Book Model with fields like so:
fields do
isbn :string
loc :string
title :string, :required
author :string, :required
edition :string
#condition :string
condition enum_string(:Very_Good, :Fair, :Good, :Fine, :Mint)
bookformat :string
askingprice :string
comments :text
timestamps
end
I want to allow the user to click on the "New Book" link in the Books
index page, enter the isbn, then press a button or click a link to do
a lookup to a restful API service like isbndb.com to get the rest of
the data about the book like author, publisher, pricing info, and
populate those fields on the New Book page, and allow the user to
review the data before clicking the Save Book or Cancel button.
I want to make this a separate action tied to a button or link as
opposed to an ajax action triggered by tabbing out of the isbn field,
because I do not want this to be done automatically when editing an
existing book.
I am assuming I will have a book_helper method called get_isbn_info
(isbn) which returns a hash of fields in my book instance, populated
or not depending on whether I got a hit, service timed out, etc..
Hope this makes things clearer. It's more the dryml and controller
setup I'm puzzled about. (That is to say more puzzled than my normal
'lets start by jumping in at the deep end' state of befuddlement)
Tom P.
On Feb 2, 10:12 am, Bryan Larsen <[email protected]> wrote:
I'm not sure if I understand you, but I think you want something like:
def new
hobo_new Foo.new(get_foo_attributes)
end
tomPorter wrote:
I do not want to automatically add the populated record to the table,
but rather have the fields in the 'New' page get populated for review
by the user prior to them pressing the 'Create foo' button.
I have a helper method that takes the known input field, does a lookup
to a third-party web API and returns a hash of all the fields required
for the item record. I don't mind waiting for the lookup to take
place.
Once the record has been created, the edit function will not present
the lookup button.
Thanks!
--
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.