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 '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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Pearlception</title>
|
||||
<title><%= (request.subdomain == '') ? 'IVAUSA' : request.subdomain.humanize %> </title>
|
||||
<%= csrf_meta_tags %>
|
||||
<%= javascript_include_tag "application", "data-turbolinks-track" => false %>
|
||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
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