route to conference#show for custom domain

This commit is contained in:
shlok007 2017-07-22 12:34:48 +05:30 committed by Shlok Srivastava
parent 1a5aa14e2c
commit 0ac5d18ef2
5 changed files with 30 additions and 6 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: 20170807092805) do
ActiveRecord::Schema.define(version: 20170816203325) 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: 20170807092805) do
t.integer "end_hour", default: 20
t.integer "organization_id"
t.integer "ticket_layout", default: 0
t.string "custom_domain"
t.integer "booth_limit", default: 0
end
@ -511,10 +512,10 @@ ActiveRecord::Schema.define(version: 20170807092805) do
create_table "tickets", force: :cascade do |t|
t.integer "conference_id"
t.string "title", null: false
t.string "title", null: false
t.text "description"
t.integer "price_cents", default: 0, null: false
t.string "price_currency", default: "USD", null: false
t.integer "price_cents", default: 0, null: false
t.string "price_currency", default: "USD", null: false
t.boolean "registration_ticket", default: false
end
@ -572,6 +573,7 @@ ActiveRecord::Schema.define(version: 20170807092805) do
t.boolean "is_admin", default: false
t.string "username"
t.boolean "is_disabled", default: false
t.string "token"
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true