socialforge/config/initializers/subdomain.rb

30 lines
661 B
Ruby
Raw Normal View History

2016-01-14 20:37:56 +08:00
class Subdomain
2016-02-02 12:40:00 +08:00
def initialize(opt={})
@opt = {}.merge(opt)
end
2016-01-14 20:37:56 +08:00
def matches?(request)
2016-02-02 12:40:00 +08:00
puts request.path_parameters
2016-02-02 17:36:11 +08:00
o = ::Secdomain.where(subname: request.subdomain).first
2016-02-02 12:40:00 +08:00
if(@opt[:sub])
if o && o.sub_type == 2
2016-02-02 12:40:00 +08:00
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
2016-01-14 20:37:56 +08:00
end
end