route to conference#show for custom domain

This commit is contained in:
shlok007 2017-07-22 12:34:48 +05:30
parent edd0024a17
commit 3e7d6e4b04
5 changed files with 26 additions and 3 deletions

View file

@ -9,10 +9,17 @@ class ConferencesController < ApplicationController
@antiquated = @conferences - @current
end
def show; end
def show
# have to change "localhost" to ENV['OSEM_HOSTNAME'] in production
check_custom_domain if request.host != 'localhost'
end
private
def check_custom_domain
@conference = @conference.custom_domain.present? ? Conference.find_by(custom_domain: request.domain) : @conference
end
def respond_to_options
respond_to do |format|
format.html { head :ok }

View file

@ -0,0 +1,6 @@
class DomainConstraint
def self.matches?(request)
@domains = Conference.pluck(:custom_domain).compact
@domains.include?(request.domain)
end
end

View file

@ -1,5 +1,9 @@
Osem::Application.routes.draw do
constraints DomainConstraint do
get '/', to: 'conferences#show'
end
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
devise_for :users, controllers: { registrations: :registrations }
else

View file

@ -0,0 +1,5 @@
class AddCustomDomainToConferences < ActiveRecord::Migration
def change
add_column :conferences, :custom_domain, :string
end
end

View file

@ -11,10 +11,10 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170721001700) do
ActiveRecord::Schema.define(version: 20170721184810) do
create_table "ahoy_events", force: :cascade do |t|
t.integer "visit_id"
t.uuid "visit_id", limit: 16
t.integer "user_id"
t.string "name"
t.text "properties"
@ -127,6 +127,7 @@ ActiveRecord::Schema.define(version: 20170721001700) do
t.integer "end_hour", default: 20
t.integer "organization_id"
t.integer "ticket_layout", default: 0
t.string "custom_domain"
end
add_index "conferences", ["organization_id"], name: "index_conferences_on_organization_id"