简体   繁体   English

将条纹添加到Rails应用程序

[英]Adding stripe to rails app

For my rails app, there are two parts. 对于我的Rails应用程序,有两个部分。

1) The actual site/app. 1)实际的网站/应用。

2) Site for businesses to pay to advertise. 2)网站供企业付费做广告。

The app is already built. 该应用程序已构建。 It's a simple crud system using devise for user logins. 这是一个使用devise进行用户登录的简单系统。 I'm not using SSL for this. 我没有为此使用SSL。

For the business site, I simply want to have a form to enter in billing info and to be able to create an account. 对于商业网站,我只想拥有一个表单以输入帐单信息并能够创建一个帐户。 For the payments, I would like to use stripe. 对于付款,我想使用条纹。 So, this site needs SSL. 因此,此站点需要SSL。 I would like this site to be on a subdomain of the same domain the app is on. 我希望此网站位于应用程序所在域的子域中。 So the main app is on example.com and the business site is on business.example.com. 因此,主应用程序位于example.com上,而商务网站位于business.example.com上。

Should I split these into two different apps? 我应该将它们分成两个不同的应用程序吗? If they should be one app, how do I get the separate site to point to the subdomain and use SSL? 如果它们应该是一个应用程序,我如何获得单独的站点以指向子域并使用SSL? Do I create a separate devise login system as well? 我是否还要创建一个单独的devise登录系统?

Should I split these into two different apps? 我应该将它们分成两个不同的应用程序吗?

You can, but it's not necessary. 您可以,但这不是必需的。 However, because your users will presumably be the same across the actual site and the business site, it'd be simpler to utilize a single app, rather than persisting the same users across two apps. 但是,由于您的用户在实际站点和企业站点上可能是相同的,因此使用单个应用程序要比在两个应用程序中保留相同的用户要容易得多。

If they should be one app, how do I get the separate site to point to the subdomain and use SSL? 如果它们应该是一个应用程序,我如何获得单独的站点以指向子域并使用SSL?

There's some fairly complex logic involved with accomplishing this, including making modifications to your hosts file, middleware, and routes. 完成此过程涉及一些相当复杂的逻辑,包括对您的主机文件,中间件和路由进行修改。 I've found this Ryan Bates' tutorial to be very helpful in setting up my own multi-subdomain installations. 我发现本Ryan Bates的教程对于设置自己的多子域安装非常有帮助。

As far as SSL goes, you'll need to configure this in both your Rails app as well as on your production server. 就SSL而言,您需要在Rails应用程序和生产服务器中都进行配置。 You're evidently working with Heroku , so you may benefit from reading Heroku's docs on setting up SSL on their end. 显然您正在使用Heroku ,因此,阅读Heroku的文档中关于设置SSL 的文档可能会有所帮助

From a Rails perspective, a simpler ground-based approach towards enabling SSL may be to specify that all routes be SSL encrypted: 从Rails的角度来看,启用SSL的一种更简单的基于地面的方法可能是指定所有路由都经过SSL加密:

MyApplication::Application.routes.draw do
  resources :sessions, :constraints => { :protocol => "https" }
end

Alternatively, you can declare specific routes to be encrypted: 或者,您可以声明要加密的特定路由:

MyApplication::Application.routes.draw do
  scope :constraints => { :protocol => "https" } do 
    # All your SSL routes.
  end
end

You can also look at force_ssl to protect controller access on an action-by-action basis. 您还可以查看force_sslforce_ssl地保护控制器访问。

Do I create a separate devise login system as well? 我是否还要创建一个单独的devise登录系统?

If you're running on a single app, then you can utilize a single Devise installation. 如果您在单个应用程序上运行,则可以利用单个Devise安装。 This presumes, of course, that the users of your actual site will also be users of your business site. 当然,这假定您的实际站点的用户也将是您的业务站点的用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM