Skip to content

Commit ac054bf

Browse files
committed
Fix ActionView::MissingTemplate for static controller
1 parent 02acd51 commit ac054bf

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module InertiaRails
22
class StaticController < InertiaRails.configuration.parent_controller.constantize
33
def static
4-
render inertia: params[:component]
4+
respond_to do |format|
5+
format.html { render inertia: params[:component] }
6+
end
57
end
68
end
79
end

spec/inertia/rendering_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
before { get inertia_route_path }
6363

6464
it { is_expected.to include inertia_div(page) }
65+
66+
context 'with non html format' do
67+
it 'raises UnknownFormat error' do
68+
expect { get '/inertia_route.json' }.to raise_error(ActionController::UnknownFormat)
69+
end
70+
end
6571
end
6672

6773
context 'via a resource inertia route' do

0 commit comments

Comments
 (0)