0

Ok so im really lost and not even too sure what to post here for information.

I am Brand new to multi tenancy, i have followed a tutorial on using the apartment gem. Everything is working perfectly on lvh.me:3000, however when I push the app to Heroku, it pushes up fine no errors, but when i attrmpt to go to my domain pv-development@herokuapp.com it redirects me to the heroku home page???

Please help here.. Let me know what i need to post here for a possible solution.. I dont even know where this could be stemming from!

Thanks in advance for you patients!

EDIT #1

This is what my log just gave me from heroku:

Apartment::Tenant Not Found (One of the following schema(s) is invalid:
Shawn Wilson
  • 1,311
  • 14
  • 40

2 Answers2

2

This error might occur when you don't have the tenant in your database. Try after creating it.

Similar issue in Github

Jayaprakash
  • 1,407
  • 1
  • 9
  • 19
  • makes sense but its supposed to default to the non subdomain home page for someone to create an account.. not sure why a schema needs to exist with a user if there is no user to put in it? – Shawn Wilson Oct 12 '16 at 09:55
  • I am not completely sure about non subdomain. But if you want to use generic subdomains like www, app, as your sign up/ login screen, you can exclude that subdomains in apartment.rb file and then you can configure routes accordingly. Ref - http://www.verecom.com/posts/how-to-create-a-multi-tenant-rails-application-subdomain-approach – Jayaprakash Oct 12 '16 at 10:06
  • its all good i have my top lvl domain and wildcard domain set up in heroku.. it is set right now for subdomain.patrolvault.com/users/sign_in everything is jiving in localhost just the migration to Heroku is a sitck in the mud lol – Shawn Wilson Oct 12 '16 at 10:11
  • Did you create CNAME for your heroku URL and subdomain settings like this - https://github.com/influitive/apartment/issues/4? – Jayaprakash Oct 12 '16 at 11:01
  • Yes I have www.patrolvault.net, patrolvault.net and *.patrolvault.net all listed in heroku – Shawn Wilson Oct 13 '16 at 05:15
1

This was occuring for several reasons, At the end of the day it was resolved by using a DNS Manager that actually supports wildcard domains ie. Zerigo DNS. i was initially using cloudflare however they only support wildcard domains on the enterprise lvl account.

I also added:

  def set_mailer_host
    if Rails.env.development?
      subdomain = current_account ? "#{current_account.subdomain}." : ""
      ActionMailer::Base.default_url_options[:host] = "#{subdomain}lvh.me:3000"
    else
      subdomain = current_account ? "#{current_account.subdomain}." : ""
      ActionMailer::Base.default_url_options[:host] = "#{subdomain}patrolvault.co"
    end
  end 

to my application controller and preloaded the postgresql addon into my heroku addons before I pushed the app up.

adding rails_12factor also cleaned things up a bit.

Thanks to @Jayaprakash for his assistance in troubleshooting this and providing links to reference.

Shawn Wilson
  • 1,311
  • 14
  • 40