Let’s say I have a appointment scheduling web app and there are some parts of the Web app that are public for everyone to see, such as Staff or a Request an appointment page. But I want these sections to be visible with the clients domain. How should the domain settings to be adjusted?
Share
There’s multiple things you could be saying here. If you have an appointment scheduling app with a public and private aspect of the application, you can use access control in Rails. For example, people in a Staff role are going to fill/manage/view appointments but clients/customers can only request appointments. This is pretty easy and doesn’t have anything to do with a (DNS) domain (btw, a domain can mean many things so you need to say DNS domain or security domain or problem domain).
You can use an authentication gem (Devise, Authlogic, Sorcery) to identify users of the systems (they login with a password etc). After someone is identified, they can be authorized (or denied) functionality of the site (with a gem like CanCan). Give your staff users a role called staff. Define staff as being able to manage all Appointments but customers only being able to read and create Appointments.
http://asciicasts.com/episodes/192-authorization-with-cancan
If you are trying to split up the site in this way with DNS domains, that’s not a good way to go. But, if you really do have all this authorization and authentication worked out and are asking a DNS question, let’s think about this.
You are trying to have /public be http://www.bizcorp.com and the rest of the app be somethingterrible.heroku.com? That’s tricky because the rails app bundles /public and you need a way to split the two based on something. You can do this in rails 3 but you’d be splitting in routes.rb for a given REST resource which is really shared between two domains (appointments). So now my appointments controller can’t handle all appointments. I have to route based on a domain name match. So you’d either need to figure out if splitting on domain is really the smart thing to do or you’d need to hack together a PublicAppointments controller and a StaffAppointments controller which is breaking DRY.
There’s more here on how to do the routes.rb matching for subdomains and top level domains:
http://asciicasts.com/episodes/221-subdomains-in-rails-3
I’d go the authorization route and put the whole site on the customer’s domain. Roles handle the public and private functionality and my URLs don’t have to change everywhere. I’d only go with the DNS hackery if I was in a crazy virtual hosted environment or some weird networking constraint.
Hope this gives you some ideas.