Skip to content

Add parent_controller config option #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 18, 2025

Conversation

skryukov
Copy link
Contributor

parent_controller

Specifies the base controller class for the internal StaticController used to render static Inertia pages.

By default, InertiaRails creates a StaticController that inherits from ApplicationController. You can use this option to specify a different base controller (for example, to include custom authentication, layout, or before actions).

Default: '::ApplicationController'

Example

Suppose you have a custom base controller:

class MyCustomBaseController < ApplicationController
  before_action :authenticate_user!
end

Configure InertiaRails to use it:

InertiaRails.configure do |config|
  config.parent_controller = 'MyCustomBaseController'
end

Now, the internal StaticController will inherit from MyCustomBaseController, and all static Inertia pages will require authentication.

When to Use

  • When you need to add custom before actions, filters, or helpers to static Inertia pages.
  • When your application has multiple base controllers and you want to use a specific one for static pages.

@skryukov skryukov force-pushed the parent-controller-config branch from 1369e20 to 8985706 Compare June 12, 2025 12:03
@bknoles bknoles merged commit eb169df into inertiajs:master Jun 18, 2025
18 checks passed
@skryukov skryukov deleted the parent-controller-config branch June 18, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants