Wow. That really is automagical. So now I have a nested form.
<customer>
(+)
If I press (+), I get
<customer>
<rental> (+)
and so on. I actually have nested "bill" and "payment" models under rental,
since I'd like to enter an initial deposit when the rental is created.
But when is Rental#new_for_customer called? When I press +, it seems it is
not. Even before I press + there are hidden forms already there - + seems to
just make them visible. If I want to populate the rental form after I enter
some customer data, what could I do? Putting code into the controller seems to
have no effect.
Alternatively, I could use a multistep "Wizard"-ish kind of pattern for
creating these things - it would just be cool to have them all on the same
page. Is there a way to combine these approaches? Use a multistep pattern,
but all on the same page? Or just *look* like its on the same page?
Mark
On Mar 1, 2011, at 1:23 PM, Todd A. Jacobs wrote:
> On Mar 1, 9:22 am, Mark Sobkowicz <[email protected]> wrote:
>> I have two models Customer and Rental. Customer has_many :rentals, Rental
>> belongs_to :customer.
>
> Assuming you're using DRYML and haven't overridden the views, this is
> controlled in the model. You just need to add:
>
> has_many :rentals, :accessible => true, :dependent => :destroy
> children :rentals
> validates_associated :rentals
>
> to your customers.rb model, and Hobo will automagically build the
> right forms for simultaneous record creation for you.
>
> --
> 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.
>
--
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.