mirror of
https://github.com/oonyeje/Pearlception_Website_RoR.git
synced 2025-12-25 03:37:40 +00:00
subdomain routing now working to route application to proper app.
- This will need to revamped later on to potentially have a rack app serving the different rails applications and static website.
This commit is contained in:
parent
9c045d129f
commit
86e1dace76
@ -42,6 +42,7 @@ gem 'kaminari'
|
|||||||
gem 'bootstrap-popover-rails'
|
gem 'bootstrap-popover-rails'
|
||||||
gem 'apartment'
|
gem 'apartment'
|
||||||
gem 'high_voltage', '~> 3.0.0'
|
gem 'high_voltage', '~> 3.0.0'
|
||||||
|
gem 'rack-subdomain'
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||||
|
|||||||
@ -132,6 +132,7 @@ GEM
|
|||||||
pry (>= 0.9.11)
|
pry (>= 0.9.11)
|
||||||
puma (3.6.2)
|
puma (3.6.2)
|
||||||
rack (2.0.1)
|
rack (2.0.1)
|
||||||
|
rack-subdomain (0.0.2)
|
||||||
rack-test (0.6.3)
|
rack-test (0.6.3)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
rails (5.0.1)
|
rails (5.0.1)
|
||||||
@ -227,6 +228,7 @@ DEPENDENCIES
|
|||||||
pry-byebug
|
pry-byebug
|
||||||
pry-stack_explorer
|
pry-stack_explorer
|
||||||
puma (~> 3.0)
|
puma (~> 3.0)
|
||||||
|
rack-subdomain
|
||||||
rails (~> 5.0.1)
|
rails (~> 5.0.1)
|
||||||
sass-rails (~> 5.0)
|
sass-rails (~> 5.0)
|
||||||
spring
|
spring
|
||||||
|
|||||||
@ -13,10 +13,9 @@ class SessionsController < Devise::RegistrationsController
|
|||||||
redirect_to "/signin"
|
redirect_to "/signin"
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
super
|
|
||||||
#Do we need this code below? It was never running before
|
#Do we need this code below? It was never running before
|
||||||
resource = warden.authenticate!(:scope => :user)
|
#resource = warden.authenticate!(:scope => :user)
|
||||||
sign_in(:user, resource)
|
sign_in(@user)
|
||||||
if !current_user.admin
|
if !current_user.admin
|
||||||
Apartment::Tenant.switch!(Company.find(current_user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
Apartment::Tenant.switch!(Company.find(current_user.company_id).company_name.gsub(/'/,'').gsub(/\s/,''))
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Pearlception</title>
|
<title><%= (request.subdomain == '') ? 'IVAUSA' : request.subdomain.humanize %> </title>
|
||||||
<%= csrf_meta_tags %>
|
<%= csrf_meta_tags %>
|
||||||
<%= javascript_include_tag "application", "data-turbolinks-track" => false %>
|
<%= javascript_include_tag "application", "data-turbolinks-track" => false %>
|
||||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||||
|
|||||||
@ -2,4 +2,26 @@
|
|||||||
|
|
||||||
require_relative 'config/environment'
|
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
|
run Rails.application
|
||||||
|
|||||||
@ -10,6 +10,7 @@ require 'apartment/elevators/subdomain'
|
|||||||
#
|
#
|
||||||
# Apartment Configuration
|
# Apartment Configuration
|
||||||
#
|
#
|
||||||
|
Apartment::Elevators::Subdomain.excluded_subdomains = ['www', 'pearlception']
|
||||||
Apartment.configure do |config|
|
Apartment.configure do |config|
|
||||||
|
|
||||||
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
|
# Add any models that you do not want to be multi-tenanted, but remain in the global (public) namespace.
|
||||||
|
|||||||
@ -1,4 +1,29 @@
|
|||||||
|
require 'subdomain'
|
||||||
|
|
||||||
Rails.application.routes.draw do
|
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/home' => 'high_voltage/pages#show', id: 'home'
|
||||||
get 'pages/applications/3D' => 'high_voltage/pages#show'
|
get 'pages/applications/3D' => 'high_voltage/pages#show'
|
||||||
get 'pages/applications/application' => '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
|
config.route_drawer = HighVoltage::RouteDrawers::Root
|
||||||
end
|
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
|
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||||
end
|
end
|
||||||
|
|||||||
5
Pearlception/lib/subdomain.rb
Normal file
5
Pearlception/lib/subdomain.rb
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
class Subdomain
|
||||||
|
def self.matches?(request)
|
||||||
|
request.subdomain.present? && request.subdomain == 'pearlception'
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user