Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/ember_cli/route_helpers.rb

Instance Method Summary collapse

Instance Method Details

#mount_ember_app(app_name, to:, **options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ember_cli/route_helpers.rb', line 7

def mount_ember_app(app_name, to:, **options)
  routing_options = options.deep_merge(
    defaults: { ember_app: app_name },
  )

  routing_options.reverse_merge!(
    controller: "ember_cli/ember",
    action: "index",
    format: :html,
  )

  scope constraints: ::EmberCli::EmberConstraint.new do
    redirect_if_missing_trailing_slash = {
      constraints: EmberCli::TrailingSlashConstraint.new,
      to: redirect(-> (_, request) {
        File.join(request.original_fullpath, "")
      }),
    }

    get(to, redirect_if_missing_trailing_slash)
    get(File.join(to, "(*rest)"), routing_options)
  end

  mount_ember_assets(app_name, to: to)
end

#mount_ember_assets(app_name, to: "/") ⇒ Object



33
34
35
36
37
38
39
# File 'lib/ember_cli/route_helpers.rb', line 33

def mount_ember_assets(app_name, to: "/")
  app = ::EmberCli[app_name]

  if app.mountable?
    mount app.to_rack => to
  end
end