Okechi Onyeje f06c2ca057 Mutltiple database pattern for companies integrated
- When creating a new company as an admin, a new database containing models for Runs, Grades, Results, Machines, and Oysters is migrated and created
- When a user registers, they are automatically switched to their company's db in the server
- When a user signs in they are also automatically swithched
2017-02-16 12:34:29 -05:00

17 lines
441 B
Ruby

class SessionsController < Devise::RegistrationsController
include ApplicationHelper
#def new
# Apartment::Tenant.switch!
#end
def create
binding.pry
resource = warden.authenticate!(:scope => :user)
binding.pry
sign_in(:user, resource)
if !current_user.admin
Apartment::Tenant.switch!(Company.find(current_user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
end
redirect_to "/"
end
end