Module: Flame::Controller::PathTo
Overview
Module with methods for path or URL building
Instance Method Summary collapse
-
#path_to(*args) ⇒ Object
Look documentation at Dispatcher#path_to.
-
#path_to_back ⇒ String
Path to previous page, or to index action, or to Index controller.
-
#url_to ⇒ Object
Build a URI to the given controller and action, or path.
Instance Method Details
#path_to(*args) ⇒ Object
Look documentation at Dispatcher#path_to
10 11 12 13 14 |
# File 'lib/flame/controller/path_to.rb', line 10 def path_to(*args) add_controller_class(args) add_controller_arguments(args) @dispatcher.path_to(*args) end |
#path_to_back ⇒ String
Path to previous page, or to index action, or to Index controller
26 27 28 29 30 31 32 33 |
# File 'lib/flame/controller/path_to.rb', line 26 def path_to_back back_path = request.referer return back_path if back_path && back_path != request.url return path_to :index if self.class.actions.include?(:index) '/' end |
#url_to ⇒ Object
Build a URI to the given controller and action, or path
17 18 19 20 |
# File 'lib/flame/controller/path_to.rb', line 17 def url_to(*, **) path = build_path_for_url(*, **) Addressable::URI.join(request.base_url, path).to_s end |