inertiajs / inertia-rails

The Rails adapter for Inertia.js.

Home Page:https://inertiajs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inertia_share fails on second request

ledermann opened this issue · comments

I'm playing around with inertia_rails within a Rails 6 application like this:

class ApplicationController < ActionController::Base
  inertia_share do
    {
      foo: 42
    }
  end
end

This works fine on the first request (props include foo:42), but all subsequent requests fail (props not include foo:42). When I modify my source file (application_controller.rb) and change foo to 43, it works on the following one request, but the next requests will fail again.

This can be reproduced with the test suite when you swap the order of the two context blocks in this file:

context 'using inertia share' do
let(:props) { {name: 'Brandon', sport: 'hockey', position: 'center', number: 29} }
before { get share_path, headers: {'X-Inertia' => true} }
it { is_expected.to eq props }
end
context 'inertia share across requests' do
before do
get share_path, headers: {'X-Inertia' => true}
get empty_test_path, headers: {'X-Inertia' => true}
end
it { is_expected.to eq({}) }
end

Seems to be caused by #13.