In case you are using two actions of two different controllers, therefore you will be redirected from one to the other through a redirect_to after the session is created.
So I understand you do not want a redirection, but rather that one form appears on the same screen after the other is created, so leave the two forms in the same action, after sending the data of one, hide it and show the other.
In an action you can have instances for the two forms, while the ajax post has different actions:
RegistrationsController
def new
@session = Session.new
@user = User.new
end
end
Class SessionsController
def create
#create session here
end
end
Class UserController
def create
#create user here
user
end
In the view of your forms you will have the ajax requests:
#views/registrations/new.html.erb
$.ajax({
type: "POST",
url: "/sessions/create",
data: { "email": "[email protected]", "password": "password" }
});
$.ajax({
type: "post",
url: "/user/create",
data: { "name": "Adolph", "las_name": "Schindler" }
});