How to Use Session Object in Ruby on Rails with React

Marcin Kornek

Jun 3, 2016 • 1 min read

When trying to use fetch in React to GET, POST, etc., you can't use current_user in the controller because you don't have Session object available. Session returns:

#ActionDispatch::Request::Session:0x7ffc75e90a88 not yet loaded

Solution

You need to add credentials: 'include' to fetch params.

Read the explainer here: https://github.com/github/fetch#sending-cookies

Related topics

More posts by this author

Marcin Kornek

After obtaining a master’s degree in Civil Engineering and working on the construction site, Marcin...
codestories