diff --git a/Pearlception/Gemfile b/Pearlception/Gemfile
index 3e654aa..e4b3cfc 100644
--- a/Pearlception/Gemfile
+++ b/Pearlception/Gemfile
@@ -42,6 +42,7 @@ gem 'kaminari'
gem 'bootstrap-popover-rails'
gem 'apartment'
gem 'high_voltage', '~> 3.0.0'
+gem 'rack-subdomain'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
diff --git a/Pearlception/Gemfile.lock b/Pearlception/Gemfile.lock
index d44963e..eb8e8fc 100644
--- a/Pearlception/Gemfile.lock
+++ b/Pearlception/Gemfile.lock
@@ -132,6 +132,7 @@ GEM
pry (>= 0.9.11)
puma (3.6.2)
rack (2.0.1)
+ rack-subdomain (0.0.2)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.0.1)
@@ -227,6 +228,7 @@ DEPENDENCIES
pry-byebug
pry-stack_explorer
puma (~> 3.0)
+ rack-subdomain
rails (~> 5.0.1)
sass-rails (~> 5.0)
spring
diff --git a/Pearlception/app/controllers/sessions_controller.rb b/Pearlception/app/controllers/sessions_controller.rb
index b19f09c..29ab135 100644
--- a/Pearlception/app/controllers/sessions_controller.rb
+++ b/Pearlception/app/controllers/sessions_controller.rb
@@ -12,11 +12,10 @@ class SessionsController < Devise::RegistrationsController
if @user == nil || !@user.valid_password?(params[:password])
redirect_to "/signin"
return
- end
- super
+ end
#Do we need this code below? It was never running before
- resource = warden.authenticate!(:scope => :user)
- sign_in(:user, resource)
+ #resource = warden.authenticate!(:scope => :user)
+ sign_in(@user)
if !current_user.admin
Apartment::Tenant.switch!(Company.find(current_user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
end
diff --git a/Pearlception/app/views/layouts/application.html.erb b/Pearlception/app/views/layouts/application.html.erb
index 2dc8dbc..9b18792 100644
--- a/Pearlception/app/views/layouts/application.html.erb
+++ b/Pearlception/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
- Pearlception
+ <%= (request.subdomain == '') ? 'IVAUSA' : request.subdomain.humanize %>
<%= csrf_meta_tags %>
<%= javascript_include_tag "application", "data-turbolinks-track" => false %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
diff --git a/Pearlception/config.ru b/Pearlception/config.ru
index f7ba0b5..8baba22 100644
--- a/Pearlception/config.ru
+++ b/Pearlception/config.ru
@@ -2,4 +2,26 @@
require_relative 'config/environment'
+# require 'rack-proxy'
+
+# class AppProxy < Rack::Proxy
+# def rewrite_env(env)
+# request = Rack::Request.new(env)
+# if request.subdomain == "pearlception"
+# env["HTTP_HOST"] = "localhost:3001"
+# else
+# env["HTTP_HOST"] = "localhost:3000"
+# end
+# env
+# end
+# end
+
+# run AppProxy.new
+
+# use Rack::Subdomain, "lvh.me:3000" do
+# map 'pearlception', to: "/dashboard/:subdomain"
+# #map '', to: "/"
+# end
+
+
run Rails.application
diff --git a/Pearlception/config/initializers/apartment.rb b/Pearlception/config/initializers/apartment.rb
index dc08608..eed10f6 100644
--- a/Pearlception/config/initializers/apartment.rb
+++ b/Pearlception/config/initializers/apartment.rb
@@ -10,6 +10,7 @@ require 'apartment/elevators/subdomain'
#
# Apartment Configuration
#
+Apartment::Elevators::Subdomain.excluded_subdomains = ['www', 'pearlception']
Apartment.configure do |config|
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
diff --git a/Pearlception/config/routes.rb b/Pearlception/config/routes.rb
index 82fd4d1..53f700a 100644
--- a/Pearlception/config/routes.rb
+++ b/Pearlception/config/routes.rb
@@ -1,4 +1,29 @@
+require 'subdomain'
+
Rails.application.routes.draw do
+ constraints(Subdomain) do
+ root 'dashboard#index'
+ # More subdomain constrained routes...
+ get 'oysters/show'
+ get 'oysters/index'
+
+ #get "dashboard/pearlception" => 'dashboard#index'
+ resources :runs
+ resources :companies
+ resources :grades
+
+ devise_for :users, :controllers => {:registrations => 'registrations', :sessions => 'sessions'}
+ #devise_for :users, controllers: {:sessions => 'session'}
+ devise_scope :users do
+ get 'signin' => 'registrations#new'
+ post 'signin' => 'registrations#create'
+ get 'signin' => 'sessions#new'
+ post 'signin' => 'sessions#create'
+ end
+ end
+
+ #binding.pry
+
get 'pages/home' => 'high_voltage/pages#show', id: 'home'
get 'pages/applications/3D' => 'high_voltage/pages#show'
get 'pages/applications/application' => 'high_voltage/pages#show'
@@ -51,20 +76,6 @@ Rails.application.routes.draw do
config.route_drawer = HighVoltage::RouteDrawers::Root
end
- get 'oysters/show'
- get 'oysters/index'
-
- # root "dashboard#index"
- # resources :runs
- # resources :companies
- # resources :grades
-
- # devise_for :users, :controllers => {:registrations => 'registrations'}
- # devise_scope :users do
- # get 'signin' => 'registrations#new'
- # post 'signin' => 'registrations#create'
- # end
-
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
end
diff --git a/Pearlception/lib/subdomain.rb b/Pearlception/lib/subdomain.rb
new file mode 100644
index 0000000..28c300c
--- /dev/null
+++ b/Pearlception/lib/subdomain.rb
@@ -0,0 +1,5 @@
+class Subdomain
+ def self.matches?(request)
+ request.subdomain.present? && request.subdomain == 'pearlception'
+ end
+end
\ No newline at end of file