Class: Sessions::ApplicationController

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/sessions/application_controller.rb

Overview

Base controller for the devices page. It inherits from the HOST’s controller (config.parent_controller, “::ApplicationController” by default) so the host’s layout, helpers, auth filters, locale switching and exception handling all apply for free — the same integration style as Devise, api_keys and chats.

Authentication is a CHAIN, so both stacks work with zero configuration:

- Devise hosts: `config.authenticate_method` (:authenticate_user! by
  default) exists and runs.
- Rails 8 omakase hosts: the inherited Authentication concern already
  registered `before_action :require_authentication` on the parent —
  parent callbacks run before ours, so anonymous visitors were
  redirected before this controller does anything.
- Anything else: the final guard 404s rather than leaking the page.

NOTE: the superclass is resolved when this class is autoloaded, which in a booted app happens AFTER initializers — so ‘config.parent_controller` set in config/initializers/sessions.rb is honored, and in development the class reloads pick up config changes too.

Direct Known Subclasses

DevicesController

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

The host’s auth filters run INSIDE this engine controller (that’s the whole point of the parent_controller inheritance) — and they reference the host’s OWN route helpers (‘new_session_path` in the omakase concern, custom redirects in hand-rolled filters), which an isolated engine can’t resolve. Delegate unknown URL helpers to main_app so the host’s code works here unmodified — the standard engine idiom.



51
52
53
54
55
56
57
# File 'app/controllers/sessions/application_controller.rb', line 51

def method_missing(method, *args, &block)
  if method.to_s.end_with?("_path", "_url") && main_app.respond_to?(method)
    main_app.public_send(method, *args, &block)
  else
    super
  end
end