I think it depends on the UI. The controller is going to follow how you want
the UI to behave.
If there's two separate forms involved, then two separate controller actions is
fine.
If there's one form, collecting all info in one step, but you need the model(s)
to be updated in two steps, then if there's an association involved, one option
is to use an after_create callback to do the second update step. You just pash
a hash of the inputs which apply to that association.
So, if I read your question correctly, I think this is one path to consider...
class Proposal < ActiveRecord::Base
after_create :my_after_create
has_one :proposal_misc
# stuff....
def my_after_create
create_proposal_misc(attributes={---STUFF_COLLECTED_IN_FORM---})
end
end
-- greg willits
On Mar 6, 2012, at 9:35 PM, Chris McCann wrote:
> I'm wrestling with the best way to handle what is probably a somewhat
> common situation with controller actions and creating a new model
> instance. I need to split the :new action into two parts.
>
> The creation of a new :proposal instance is really a two-step
> operation. The first step sets up some basic features of the
> new :proposal and the second step lets the user enter all of the
> details (lots of nested attributes and other stuff).
>
> The question is, how should this be handled in a controller? Short of
> adding a proposals_controller#setup action that then redirects
> to :new, is there a more canonically correct way to do this?
>
> My Google-fu is letting me down on this, mostly because I'm having
> trouble describing what the problem is that I'm trying to solve. I'm
> going to bring this issue to the Hackfest this Thursday night as well.
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby