Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/patches/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module InertiaMapper
def inertia(*args, **options)
path = args.any? ? args.first : options
route, component = extract_route_and_component(path)
scope module: nil do
get(route, to: 'inertia_rails/static#static', defaults: { component: component }, **options)
end
get(route, to: StaticController.action(:static), defaults: { component: component }, **options)
end

private
Expand Down
3 changes: 3 additions & 0 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
scope :scoped, as: "scoped" do
inertia 'inertia_route' => 'TestComponent'
end
namespace :namespaced do
inertia 'inertia_route' => 'TestComponent'
end
resources :items do
inertia inertia_route: 'TestComponent', on: :member
inertia :inertia_route_with_default_component
Expand Down
6 changes: 6 additions & 0 deletions spec/inertia/rendering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
it { is_expected.to include inertia_div(page) }
end

context 'via a namespaced inertia route' do
before { get namespaced_inertia_route_path }

it { is_expected.to include inertia_div(page) }
end

context 'with a default component' do
let(:page) { InertiaRails::Renderer.new('inertia_route_with_default_component', controller, request, response, '').send(:page) }

Expand Down