add support for deploying to a subdirectory

This commit is contained in:
Josh
2018-06-18 10:28:47 -04:00
parent ce6ec0acfb
commit b2b2c641da
10 changed files with 74 additions and 54 deletions

View File

@ -6,7 +6,7 @@ require 'rails/all'
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Greenlight20
module Greenlight
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers

View File

@ -83,4 +83,11 @@ Rails.application.configure do
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
# Set the relative url root for deployment to a subdirectory.
if ENV['RELATIVE_URL_ROOT'].present?
config.relative_url_root = ENV['RELATIVE_URL_ROOT']
else
config.relative_url_root = ""
end
end

View File

@ -5,29 +5,12 @@ Rails.application.routes.draw do
match '/422', to: 'errors#unprocessable', via: :all
match '/500', to: 'errors#internal_error', via: :all
# Room resources.
resources :rooms, only: [:create, :show, :destroy], param: :room_uid, path: '/r'
# Extended room routes.
scope '/r/:room_uid' do
post '/', to: 'rooms#join'
post '/start', to: 'rooms#start', as: :start_room
get '/logout', to: 'rooms#logout', as: :logout_room
post '/home', to: 'rooms#home', as: :make_home
# Mange recordings.
scope '/:record_id' do
post '/', to: 'rooms#update_recording', as: :update_recording
delete '/', to: 'rooms#delete_recording', as: :delete_recording
end
end
# Signup routes.
get '/signup', to: 'users#new', as: :signup
post '/signup', to: 'users#create', as: :create_user
# User resources.
scope '/users' do
scope '/u' do
get '/:user_uid/edit', to: 'users#edit', as: :edit_user
patch '/:user_uid/edit', to: 'users#update', as: :update_user
@ -45,5 +28,22 @@ Rails.application.routes.draw do
match '/auth/:provider/callback', to: 'sessions#omniauth', via: [:get, :post], as: :omniauth_session
get '/auth/failure', to: 'sessions#fail'
# Room resources.
resources :rooms, only: [:create, :show, :destroy], param: :room_uid, path: '/'
# Extended room routes.
scope '/:room_uid' do
post '/', to: 'rooms#join'
post '/start', to: 'rooms#start', as: :start_room
get '/logout', to: 'rooms#logout', as: :logout_room
post '/home', to: 'rooms#home', as: :make_home
# Mange recordings.
scope '/:record_id' do
post '/', to: 'rooms#update_recording', as: :update_recording
delete '/', to: 'rooms#delete_recording', as: :delete_recording
end
end
root to: 'main#index'
end