Curious how you guys handle this:

Let's say I have two model objects being created by the same form. We'll call them User and Account. How would you create both or neither (validations in one may fail)? This works for me, but seems there should be a better way:

@account = Account.new(params[:account])
@user = User.new(params[:user])
if @account.save and @user.save
        @account.users << @user
        # Do something cool
else
        @account.destroy
        @user.destroy
        # Show error messages and try again
end

_______________________________________________
Sdruby mailing list
[email protected]
http://lists.sdruby.com/mailman/listinfo/sdruby

Reply via email to