File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -640,6 +640,28 @@ json.flash flash.to_h
640640** NOTE** PropsTemplate inverts the usual Rails rendering flow. PropsTemplate
641641will render Layout first, then the template when ` yield json ` is used.
642642
643+
644+ ### Layouts in API-only Rails apps
645+
646+ If your controllers inherit from ` ActionController::API ` (typical in API-only Rails apps),
647+ the layout feature won’t work out of the box, because ` ActionController::API `
648+ does not include layout support.
649+
650+ To enable layout rendering, you can include ` ActionView::Layouts ` manually,
651+ then use ` layout "your_own_layout" ` as usual:
652+
653+ ``` ruby
654+ module Api
655+ class BaseController < ActionController ::API
656+ include ActionView ::Layouts
657+
658+ layout " api"
659+ end
660+ end
661+ ```
662+
663+ Without this, Rails will silently skip the layout, which can be tricky to notice.
664+
643665## Change key format
644666By default, keys are not formatted. This is intentional. By being explicit with your keys,
645667it makes your views quicker and more easily diggable when working in JavaScript land.
You can’t perform that action at this time.
0 commit comments