Reputation: 2293
For my rails app, there are two parts.
1) The actual site/app.
2) Site for businesses to pay to advertise.
The app is already built. It's a simple crud system using devise for user logins. I'm not using SSL for this.
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. 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.
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? Do I create a separate devise login system as well?
Upvotes: 1
Views: 231
Reputation: 26193
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?
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.
As far as SSL goes, you'll need to configure this in both your Rails app as well as on your production server. You're evidently working with Heroku, so you may benefit from reading Heroku's docs on setting up SSL on their end.
From a Rails perspective, a simpler ground-based approach towards enabling SSL may be to specify that all routes be SSL encrypted:
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.
Do I create a separate devise login system as well?
If you're running on a single app, then you can utilize a single Devise installation. This presumes, of course, that the users of your actual site will also be users of your business site.
Upvotes: 1