子域名处理
This commit is contained in:
parent
f3a0e71cee
commit
28035dfc47
|
@ -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
|
||||
end
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
11
db/schema.rb
11
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"
|
||||
|
|
Loading…
Reference in New Issue