So I have a Rails app at www.myapp.com, and I have a marketing landing page at www.marketingpage.com.
What I want to happen is, when people fill out a registration form on my marketing page, for it to be managed by my Rails app.
I am thinking of just creating a view at myapp.com/mktg, then just having www.marketingpage.com redirect to myapp.com/mktg.
But, the issue with that approach is that I don't want users to see a different domain name for the registration.
How can I approach this, so that the registration on the marketing page looks and feels like it is a full 'mini-site', but it is powered by my main Rails App?
Thanks.
Edit 1
Another thing is, for the registration page at marketingpage.com, I want to use email sign-up only for Devise - so the marketingpage.com is not just 1 page. It will be 1 page, then they at least 1 or 2 more pages. So whatever domain/routing strategy, has to account for that too.
If you have an email input:
<input id="email"></input>
<button id="submit-email"></button>
you can send a jsonp (to get around same-origin restrictions) request when the button is clicked:
$('#submit-email').click(function() {
submitted_email = $('#email').value()
// client-side validations
$.ajax({
type: 'POST',
dataType: 'jsonp',
url: "http://www.myapp.com/signup",
data: { user: { email: submitted_email } },
success: function(data) {
// signup success
}
});
});
On the rails end:
class UserController
def signup
@user = User.create(params[:user])
// handle success/failure
respond_to do |format|
format.js { render :json => @user }
end
end
end
To retrieve a list of users:
$.ajax({
type: 'GET',
dataType: 'jsonp',
url: "http://www.myapp.com/users",
success: function(data) {
// populate a list
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.