It seems the redirect is only used directly in routes, so I'm wondering it is helpful anywhere. I have methods parked in a module. Any insight appreciated.
def my_method.bounce(bounceURL)
redirect bounceURL
end
"undefined method `redirect' for Motherlode:Module"
Already loaded as a helper module. Currently, the method is as follows:
def my_method.bounce(bounceURL)
redirect bounceURL
endComes up as an undefined method error:
"undefined method `redirect' for Motherlode:Module"
require 'sinatra'
module MyHelpers
def bounce
redirect '/foo'
end
end
helpers MyHelpers
get '/' do
bounce
end
$ curl -i http://localhost:4567
HTTP/1.1 302 Found
Content-Type: text/html;charset=utf-8
Location: http://localhost:4567/foo
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
Content-Length: 0
def Mymodule.bounce(bounceURL)
redirect bounceURL
end
def Mymodule.bounce(bounceURL)
redirect bounceURL
end
module Mymodule
def self.bounce(bounceURL)
redirect bounceURL
end
end
module Mymodule
def bounce(bounceURL)
redirect bounceURL
end
end
module Mymodule
end
module Mymodule
def bounce(bounceURL)
redirect bounceURL
end
end
module Mymodule
end
Mymodule.send(:define_method, :bounce) do
redirect bounceURL
end