In case you are using two actions from two different controllers, so you will be redirected from one to the other via a redirect_to after the creation of Session.
From what I understand you do not want a redirect, but rather that a form appears on the same screen after creating the other, 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 post done in ajax, have 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 your Forms view 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" }
});
It works the same as in any other language, it’s no secret. You make the request via Ajax informs you where you want the result of this request to be displayed
– user3603
So, I did here, but it seems that only one link works. I removed the require turbolinks to test and only one works without refresh. I believe it’s some silly mistake, my friend. link: http://pastebin.com/VUqxNype
– Xavier
Do yourself a big favor and put the code you think you need in your question, so it’s easier.
– user3603