Skip to content

Commit c0a3d36

Browse files
authored
Fix inertia helper for namespaced routes (#201)
1 parent e334479 commit c0a3d36

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

lib/patches/mapper.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ module InertiaMapper
33
def inertia(*args, **options)
44
path = args.any? ? args.first : options
55
route, component = extract_route_and_component(path)
6-
scope module: nil do
7-
get(route, to: 'inertia_rails/static#static', defaults: { component: component }, **options)
8-
end
6+
get(route, to: StaticController.action(:static), defaults: { component: component }, **options)
97
end
108

119
private

spec/dummy/config/routes.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
scope :scoped, as: "scoped" do
5555
inertia 'inertia_route' => 'TestComponent'
5656
end
57+
namespace :namespaced do
58+
inertia 'inertia_route' => 'TestComponent'
59+
end
5760
resources :items do
5861
inertia inertia_route: 'TestComponent', on: :member
5962
inertia :inertia_route_with_default_component

spec/inertia/rendering_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@
7676
it { is_expected.to include inertia_div(page) }
7777
end
7878

79+
context 'via a namespaced inertia route' do
80+
before { get namespaced_inertia_route_path }
81+
82+
it { is_expected.to include inertia_div(page) }
83+
end
84+
7985
context 'with a default component' do
8086
let(:page) { InertiaRails::Renderer.new('inertia_route_with_default_component', controller, request, response, '').send(:page) }
8187

0 commit comments

Comments
 (0)