[英]How do I manage registrations on a different domain than my Rails app?
So I have a Rails app at www.myapp.com, and I have a marketing landing page at www.marketingpage.com. 因此,我在www.myapp.com上有一个Rails应用程序,在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. 我想发生的是,当人们在我的营销页面上填写注册表时,由我的Rails应用程序对其进行管理。
I am thinking of just creating a view at myapp.com/mktg, then just having www.marketingpage.com redirect to myapp.com/mktg. 我正在考虑仅在myapp.com/mktg上创建视图,然后仅将www.marketingpage.com重定向到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? 我该如何处理,以使行销页面上的注册看起来和感觉像是一个完整的“微型站点”,但由我的主要Rails App提供动力?
Thanks. 谢谢。
Edit 1 编辑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. 另一件事是,对于marketingpage.com上的注册页面,我只想为Devise使用电子邮件注册,因此marketingpage.com不仅仅是一页。 It will be 1 page, then they at least 1 or 2 more pages.
这将是1页,然后至少增加1或2页。 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: 您可以在单击按钮时发送一个jsonp请求(绕开同源限制):
$('#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
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.