diff --git a/config/initializers/elasticsearch_dev_patch.rb b/config/initializers/elasticsearch_dev_patch.rb index 4eda95ee5..ac9b800ba 100644 --- a/config/initializers/elasticsearch_dev_patch.rb +++ b/config/initializers/elasticsearch_dev_patch.rb @@ -10,7 +10,7 @@ if Rails.env.development? class NoObject instance_methods.each do |m| - undef_method(m) unless [:undef_method, :method_missing].include?(m) + undef_method(m) unless [:object_id, :__send__, :undef_method, :method_missing].include?(m) end def method_missing(method, *args, &block) @@ -50,4 +50,4 @@ if Rails.env.development? end end -end \ No newline at end of file +end diff --git a/config/initializers/subdomain.rb b/config/initializers/subdomain.rb index b868e7e0b..474503339 100644 --- a/config/initializers/subdomain.rb +++ b/config/initializers/subdomain.rb @@ -1,9 +1,30 @@ class Subdomain + def initialize(opt={}) + @opt = {}.merge(opt) + end + def matches?(request) - o = Organization.where(domain: request.subdomain).first - request.path_parameters[:id] = o.id if o - !o.nil? + puts request.path_parameters + o = Secdomain.where(subname: request.subdomain).first + + if(@opt[:sub]) + if o && o.sub_type == 2 && request.path_parameters[:sub_dir_name] == 'news' + request.path_parameters[:id] = o.pid + request.path_parameters[:controller] = 'org_subfields' + request.path_parameters[:action] = 'show' + return true + end + end + + + if o && o.controller + request.path_parameters[:id] = o.pid + request.path_parameters[:controller] = o.controller + request.path_parameters[:action] = o.action + return true + end + false end end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 550642120..f4d8daf4f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -31,6 +31,15 @@ RedmineApp::Application.routes.draw do # Enable Grack support # mount Trustie::Grack.new, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post] + constraints(Subdomain.new) do + get '/', to: 'organizations#show' + end + + constraints(Subdomain.new(sub: true)) do + get '/:sub_dir_name', to: 'fake#fake' + end + + resources :shield_activities do collection do delete 'show_acts' @@ -75,16 +84,7 @@ RedmineApp::Application.routes.draw do end - constraints(Subdomain.new) do - get '/', to: 'organizations#show' - end - get '/', to: 'organizations#show', defaults: { id: 5 }, constraints: {subdomain: 'micros'} - get '/', to: 'organizations#show', defaults: { id: 23 }, constraints: {subdomain: 'nubot'} - get '/', to: 'organizations#show', defaults: { id: 1 }, constraints: {subdomain: 'team'} - get '/', to: 'users#show', defaults: {id: 7}, constraints: {subdomain: 'whm'} - get '/', to: 'users#show', defaults: {id: 5}, constraints: {subdomain: 'yg'} - get '/', to: 'users#show', defaults: {id:11}, constraints: {subdomain: 'wt'} resources :org_member do member do diff --git a/db/schema.rb b/db/schema.rb index 2e5bfde22..7b68815a8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20160128024452) do +ActiveRecord::Schema.define(:version => 20160202034530) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1534,6 +1534,15 @@ ActiveRecord::Schema.define(:version => 20160128024452) do t.string "pinyin" end + create_table "secdomains", :force => true do |t| + t.integer "sub_type" + t.string "subname" + t.integer "pid", :default => 0 + t.string "desc" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "seems_rateable_cached_ratings", :force => true do |t| t.integer "cacheable_id", :limit => 8 t.string "cacheable_type"