diff --git a/app/controllers/conferences_controller.rb b/app/controllers/conferences_controller.rb index 53e5bd6d..15a59a0c 100644 --- a/app/controllers/conferences_controller.rb +++ b/app/controllers/conferences_controller.rb @@ -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 } diff --git a/config/initializers/domain_constraint.rb b/config/initializers/domain_constraint.rb new file mode 100644 index 00000000..67e19a75 --- /dev/null +++ b/config/initializers/domain_constraint.rb @@ -0,0 +1,6 @@ +class DomainConstraint + def self.matches?(request) + @domains = Conference.pluck(:custom_domain).compact + @domains.include?(request.domain) + end +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3b955953..c4a5f6ce 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20170721184810_add_custom_domain_to_conferences.rb b/db/migrate/20170721184810_add_custom_domain_to_conferences.rb new file mode 100644 index 00000000..d5aef4fd --- /dev/null +++ b/db/migrate/20170721184810_add_custom_domain_to_conferences.rb @@ -0,0 +1,5 @@ +class AddCustomDomainToConferences < ActiveRecord::Migration + def change + add_column :conferences, :custom_domain, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 83499b33..d9949b1e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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