Rails session does not persist?

def create
@user = User.find_by(email: params[:email])
if @user && @user.authenticate(params[:password])
session[:user_id] = @user.id
render json: {
status: :created,
logged_in: true,
user: @user
}
else
render json: {status: 401}
end
byebug
end
config.middleware.use ActionDispatch::Cookies
config.middleware.use ActionDispatch::Session::CookieStore, key: '_backend_chat_app'

--

--

--

Full Stack Web Developer | antonzaharia.com

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Event.isTrusted, Safeguard Your Site from Bots

Browsers Lab — Alpha Version

Securing Elasticsearch integration on AWS within your organization

Load balanced Asp.Net Core Application with Docker, MongoDB, and Redis — Pt.6

Battery Distribution Management System

Agile Methodology for feature development of commercial product

qTest Integration with Applitools

IT Strategy Principles

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Zaharia Anton

Zaharia Anton

Full Stack Web Developer | antonzaharia.com

More from Medium

CodeClimate Setup For Ruby On Rails Project

Serializing. Not Just for Norman

Ruby on Rails — Phase 4 Project

One-to-many relationships: Active Record Associations