Reputation: 603
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.
Upvotes: 1
Views: 568
Reputation: 44370
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
Upvotes: 2