I am trying to setup a sigup form thats pretty much just like the
basecamp form. Basecamp Classic Signup
I want to create
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”
studio = Studio.new(studio_params)
return unless self.valid? && studio.valid?
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?