Merge branch 'Add-Static-Files' of https://github.com/oonyeje/Pearlception_Website_RoR into Add-Static-Files

This commit is contained in:
bmv root 2017-04-20 12:30:41 -04:00
commit e007c1040b
8 changed files with 60 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -12,11 +12,10 @@ class SessionsController < Devise::RegistrationsController
if @user == nil || !@user.valid_password?(params[:password]) if @user == nil || !@user.valid_password?(params[:password])
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

View File

@ -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' %>

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -0,0 +1,5 @@
class Subdomain
def self.matches?(request)
request.subdomain.present? && request.subdomain == 'pearlception'
end
end