Hmmmm ... Ok. So let's say I have a person object (instance of Person)
which has a home address (instance of Address) and a business address
object (instance of Address). I set up the Person like this:

class Address < ActiveRecord::Base
  hobo_model
  fields{
    ... bunch of fields ...
  }
  has_many :people
end

class People < ActiveRecord::Base
  hobo_model
  fields {
    ... bunch of fields ...
  }
  belongs_to :home, :class_name => "Address", :foreign_key => "home_id"
  belongs_to :work, :class_name => "Address", :foreign_key => "work_id"
end

So, given that you want to create a combined "new" screen which would allow
me to use two copies of a tag like "address-editor" to add both a home and
a business address in-line with the rest of the info about a person on the
"new" person screen, how would one accomplish that? I had thought to do
something like the following in the "new" method of the controller:

  def new
  @person = Person.new
  @work = Address.new
  @home = Address.new
    hobo_new
  end

and then do sort of as I had suggested in my example above and have these
things edited directly and then, in the "save" method of the controller,
build the model structure from what the form passes back to me before
calling "save" on it.

Any other suggestions? Surely, someone else must have had to have an
"inline" editor for a "child" model like this, no?

Again, any help for a newbie here would be greatly appreciated!

Regards,

Peter

On Thu, Feb 2, 2012 at 11:17 AM, kevinpfromnm <[email protected]>wrote:

> In order for the create action to handle multiple models they have to be
> related to a single original model and have the :accessible => true flag on
> the association.
>
> For it to work as an ajax editor, you'd need individual editor calls on
> each field (plus I think the way you're using table might be throwing off
> the implicit context).  But, an in place editor won't work on an unsaved
> object or possibly worse, will have the possibility of setting up orphaned
> records (go to new form, main object unsaved, children unsaved, make edit
> to child, child now saved, leave new form, no main object).
>
> I would guess you either want these as accessible associations or you'll
> need a two step process where you do the new object first, then have the
> sub-items setup on a second page, like the show view.  The accessible
> association is by far the more common pattern ->
> http://cookbook.hobocentral.net/manual/multi_model_forms.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/hobousers/-/-GFpDitcgzEJ.
>
> 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.
>

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