Module: Flame::Controller::PathTo

Includes:
Memery
Included in:
Flame::Controller
Defined in:
lib/flame/controller/path_to.rb

Overview

Module with methods for path or URL building

Instance Method Summary collapse

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_backString

Path to previous page, or to index action, or to Index controller

Returns:

  • (String)

    path to previous page or to index



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_toObject

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