Module: Roda::RodaPlugins::RedirectPath
- Defined in:
- lib/roda/plugins/redirect_path.rb
Overview
The redirect_path plugin builds on top of the path plugin, and allows the r.redirect
method to be passed a non-string object that will be passed to path
, and redirect to the result of path
.
In the second argument, you can provide a suffix to the generated path. However, in this case you cannot provide a non-default redirect status in the same call).
Example:
Foo = Struct.new(:id)
foo = Foo.new(1)
plugin :path
path Foo do |foo|
"/foo/#{foo.id}"
end
route do |r|
r.get "example" do
# redirects to /foo/1
r.redirect(foo)
end
r.get "suffix-example" do
# redirects to /foo/1/status
r.redirect(foo, "/status")
end
end
Defined Under Namespace
Modules: RequestMethods
Class Method Summary collapse
Class Method Details
.load_dependencies(app) ⇒ Object
37 38 39 |
# File 'lib/roda/plugins/redirect_path.rb', line 37 def self.load_dependencies(app) app.plugin :path end |