> Bob, curious, did you ever get this sorted?
> http://groups.google.com/group/hobousers/browse_thread/thread/35e85595f8f2086f/baa603cbe427c14e?lnk=gst&q=auto_actions_for#baa603cbe427c14e
>
> It appears that that post here is slightly connected and I see other
> use cases of auto_actions_for, however each time it seems that child
> models are being manipulated rather than parents. Is this the case?
> Is my problem that you must use auto_actions_for from a controller
> that is a child model to a parent that is rendering the input form(s)?
>
> If so I'm assuming that I need to rethink things here a bit.
>
> Thanks again guys for any help / enlightenment on this matter.
I'm guessing you've got a many-to-many between Property and PropertyType; the issue, here as in Bob's case, is that auto_actions_for is somewhat specialized for handling a simpler sort of relation. To be precise, here's the case it's intended for:
class ParentThing
has_many :things
end
class Thing
belongs_to :parent_thing
end
class ThingsController
auto_actions_for :parent_thing, [:index, :new, :create]
end
As you've both noted, trying this on either side of a has_many :through isn't so good.
As to your other question (regarding the selector + new form), you might want to check out Bryan's select-one-or-new-dialog in hobo-jquery; I'm not certain it will do what you've described, but it's certainly a step in the right direction.
--Matt Jones
A couple things:
- you definitely want to check out select-one-or-new; this is *exactly* the use case that was designed for.
- auto_actions_for isn't going to do anything relevant here, especially for the new page; it's hard to make a request to /properties/:property_id/property_types/new when :property_id isn't set yet.
The typical usage of auto_actions_for in your scenario would be a somewhat different flow; you'd locate (or create new) a particular PropertyType and then hit a route like /property_types/:property_type_id/properties/new to create a new record with that type.
--Matt Jones
> Matt: THANK YOU! Tremendous. I am curious, I am converting an app
> that used to have the following scenario:
>
> There were fields such as "Elementary School" and "Heating System"
> where they were simply table attributes and not actual children to a
> parent table. The way it worked was that there was a special control
> via javascript that was a textfield with a drop down. This control
> would query the db so as to pull all, for example, "Cooling System"
> entries from all "Cooling System" attributes in the table to populate
> the drop down and allow an autofill as the user typed of the correct
> entry if one already existed. The reason this is useful is that these
> items could change pretty regularly. A modern control that would
> currently fit this bill is: http://coffeescripter.com/code/editable-select/
> Is this currently possible with Hobo?
>
Bryan recently added something of the editable-dropdown flavor:
http://groups.google.com/group/hobousers/browse_thread/thread/d3dafe2ab97cac03?hl=en
Not sure if this exactly fits your description, though.
> Additionally Matt, it seems that the "Hobo way" of adding images to
> something is to add a record and then immediately offer back the show
> page and then add images or other things with that. Is there a way to
> allow images and other such dynamic things (such as in this case I'm
> also adding "Rooms" in a dynamic way) on the creation page? I realize
> it's a chicken and egg scenario where you don't have the parent record
> yet to which to attach them, so I don't know if this has been
> considered so as to make tmp records and then reassign them upon
> parent record creation...?
You can create multiple associated records in one go (even on a 'new' record) with input-many and friends. The biggest gotcha with things like that and image upload is that it's always messy to stash images someplace when a record fails validation (and uploading them more than once is terrible UX).
--Matt Jones