# Multiple Models one form and validations ... no transactions(mongo)

**URL:** <https://www.ruby-forum.com/t/multiple-models-one-form-and-validations-no-transactions-mongo/188999>\
**Category:** Rails\
**Created:** [May 21, 2010, 5:52pm UTC](https://www.ruby-forum.com/t/multiple-models-one-form-and-validations-no-transactions-mongo/188999 "2010-05-21T17:52:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![magic6435](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/57b2e6/32.png) [@magic6435](https://www.ruby-forum.com/u/magic6435)\
**Post date:** [May 21, 2010, 5:52pm UTC](https://www.ruby-forum.com/t/multiple-models-one-form-and-validations-no-transactions-mongo/188999/1 "2010-05-21T17:52:47Z")

</div>

I am trying to setup a sigup form thats pretty much just like the  
basecamp form. [Basecamp Classic Signup](https://signup.37signals.com/basecamp/Plus/signup/new)

I want to create  
a User  
a Studio  
and a Subscription(chargify)

a Subscription belongs to a Studio and not to a User. User gets tagged  
onto a Studio via an admin array.

Is there any way to do this all in one form and still get back  
validation errors etc without using a transaction to roll everything  
back? Right now i have the problem where if the User gets created but  
then the Studio or Subscription fails I then have a User sitting in  
the db when the form re-renders “new” and they click save again then  
they will get a error about “username already exists” blah blah blah.

Right now i am creating everything via the User model with all the  
extra fields on attr\_accessor and a method called  
“create\_and\_subscribe”. Is that the best practice for this? and if so  
how do i still get back the validations from the other model like  
Studio. Since i don’t have transactions the best i could think of was  
this at the head of “create\_and\_subscribe”

def create\_and\_subscribe(product\_id)  
studio = Studio.new(studio\_params)  
return unless self.valid? && studio.valid?  
…  
…  
end

that way i at least know they are valid then i actually create them if  
the call to Chargify is successful.

Thanks for any help this has been driving me nuts.

Ps.I wonder if this is better suited to the mongo form since my  
problem is coming from lack of transactions?
