I have a more complex constraints for routing, why is this simple example not working:
class FooBar
def self.matches?(request)
true
end
end
get ':foo', to: redirect('/bar'), constraints: FooBar.new
All I get is
Invalid constraint: #<FooBar:0x007f87f14dce40> must respond to :call or :matches?
Any ideas how to get it work? Thanks.
must respond to :call or :matches?
Whats mean the instance of the FooBar must have a method(not the class method like in your code) matches
:
class FooBar
def matches?(request)
true
end
end
Or responde to call
, proc
in my example:
FooBar = proc do |request|
# here goes code
end
get ':foo', to: redirect('/bar'), constraints: FooBar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.