带有请求子域的条件回调。可能吗?
Conditional callback with request sub domain. is it possible?
我试过这样的东西
class SomeController < ApplicationController
before_action :something, if: request.subdomain == "specific"
end
但是在这里我无法访问请求对象并且它抛出错误。
undefined local variable or method `request' for SomeController:Class
有人可以建议我如何实现吗?
你可以这样做
before_action :something
def something
if request.subdomain == "specific"
your code
end
end
使用过程,
class SomeController < ApplicationController
before_action :something, if: proc { |c| c.request.subdomain == "specific" }
end
我试过这样的东西
class SomeController < ApplicationController
before_action :something, if: request.subdomain == "specific"
end
但是在这里我无法访问请求对象并且它抛出错误。
undefined local variable or method `request' for SomeController:Class
有人可以建议我如何实现吗?
你可以这样做
before_action :something
def something
if request.subdomain == "specific"
your code
end
end
使用过程,
class SomeController < ApplicationController
before_action :something, if: proc { |c| c.request.subdomain == "specific" }
end