简体   繁体   English

我如何在与Rails应用程序不同的域上管理注册?

[英]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.

相关问题 Rails 5:如何在公用文件夹中获取错误页面以使其他语言环境显示除“ en”以外的其他内容? - Rails 5: How Do I Get My Error Pages in the Public Folder for Different Locales to Display Other than "en? 如何在Rails中执行“管理我的承诺” - How to do a “manage my pledge” in Rails 如何在Rails 4中管理不同的布局? - How I can manage different layout in Rails 4? 如何使设计使用不同的控制器而不是注册? - how to make devise use different controller rather than registrations? 如何在我的Rails应用程序中管理其他heroku应用程序? - How can manage other heroku app in my rails app? 如何在Rails应用程序中管理其他数据库中的架构 - How to manage schema in a different database from within a rails app 如何管理生产的Rails应用程序中定期重新创建的一组mysql表? - How do I manage a set of mysql tables in a production Rails app that are periodically recreated? 如何让facebook页面管理员只选择他们希望我的应用管理的特定页面(manage_pages) - How do I allow a facebook page admin to select only the specific pages they want my app to manage(manage_pages) 如何在Rails中按域/子域进行路由 - How do I route by domain / subdomain in rails 我如何解决这个“无法加载这样的文件 -- /home/max/app_project/app/controllers/registrations_controller.rb” - How do i fix this "cannot load such file -- /home/max/app_project/app/controllers/registrations_controller.rb"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM