1

I need to make a Rail 3 app "SaaS"-fied. I know there are different opinions on multi-tenanncy / data-separation etc. Currently I'm going with "total data separation" option where on each sign-up, I launch a new Heroku app. I've a launch page which is at mydomain.com and www.mydomain.com. I also have CNAME entry (in Zerigo) *.mydomain.com pointing to proxy.heroku.com (Heroku Mesh). I've gone through this link as well - Ruby on Rails: how to design a SaaS infrastructure?. My requirement is almost identical to this. I understand that following things should be done when a new user signs-up for the SaaS -

  1. select app name: app-name.mydomain.com
  2. username/password/role (optional) and pricing option
  3. Then deploy code to a new Heroku instance (and may be simplify repetitive Heroku tasks by https://github.com/darkbushido/heroku-rails-saas)
  4. Add Heroku domain:add .mydomain.com
  5. Use Heroku config:add to add the choices from step #2

Everything looks fine. But the problem is, can we automate the process? I've seen couple of relevant gems in http://rubydoc.info/gems/s but not sure about them. Any suggestion will be awesome.

Thanks

Community
  • 1
  • 1
dbose
  • 31
  • 4

1 Answers1

0

I don't see a reason why it shouldn't be possible to automate this. It could be done in a background job (when a user has signed up). In that job you can use the heroku gem. Take a look at https://github.com/heroku/heroku/blob/master/lib/heroku/client.rb to see the methods you can call.

Here is an example that lists all Heroku apps for an account:

require "heroku"
heroku = Heroku::Client.new("email@example.com", "password")

# List all heroku apps
heroku.list.each do |app|
  puts app[0]
end

I hope this helps!

agronemann
  • 687
  • 4
  • 16
  • Thanks for the info. Although I can create new Heroku app by API (I've did this already), there is no way to push the code from BitBucket or GitHub from my launch app (www.mydomain.com) which itself resides on Heroku, which has a read-only filesystem. I need a third party to pull from BitBucket and then push to git repo of new-ly-created Heroku-app (by API). – dbose May 16 '12 at 18:50
  • I've solved the problem by going for Apartment gem, which is not perfect but will serve my purpose. Thanks Highcode for your response – dbose Jun 20 '12 at 14:18