title: ActionDispatch::Cookies::CookieOverflow occurs when trying to return relevant values using devise token auth
body: <h1>Assumption</h1>
  <p>I'm using <code>devise token auth</code> in Rails, and when I try to return values related to user information created with <code>devise token auth</code>, I get a <code>cookie over capacity</code> error. If I use <code>model name.all</code> the error does not occur.
  How can I resolve this error?</p>
  <h1>What we want to solve</h1>
  <ul>
  <li>I want to resolve a <code>ActionDispatch::Cookies::CookieOverflow</code> error and return the value associated with <code>user</code> created with <code>devise token auth</code>.</li>
  </ul>
  <h1>Code</h1>
  <p>Controller</p>
  <pre class="lang-rb prettyprint-override"><code>class Api::V1::PostsController &lt; ApplicationController
  
    def index
      # posts = Post.all
      posts = current_api_v1_user.posts  # ActionDispatch::Cookies::CookieOverflow
  
      render json: posts, status: :ok
    end
  </code></pre>
  <h1>Error</h1>
  <pre><code>api_1    | ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow):
  </code></pre>
  <h1>I tried</h1>
  <ul>
  <li>The only thing I could come up with in my research was to use <code>activerecord-session_store</code> gem, but I guess I was wrong and the error was not resolved.</li>
  </ul>
  <p><strong>gem</strong></p>
  <pre class="lang-rb prettyprint-override"><code>source 'https://rubygems.org'
  git_source(:github) { |repo| &quot;https://github.com/#{repo}.git&quot; }
  
  ruby '2.7.1'
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '~&gt; 6.0.3', '&gt;= 6.0.3.6'
  # Use postgresql as the database for Active Record
  gem 'pg', '&gt;= 0.18', '&lt; 2.0'
  # Use Puma as the app server
  gem 'puma', '~&gt; 4.1'
  # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
  gem 'jbuilder', '~&gt; 2.7'
  # Use Redis adapter to run Action Cable in production
  # gem 'redis', '~&gt; 4.0'
  # Use Active Model has_secure_password
  gem 'bcrypt', '~&gt; 3.1.7'
  ・
  ・
  ・
  
  AJAX possible
  gem 'rack-cors'
  
  gem 'active_model_serializers'
  
  # JWT Doc: https://github.com/jwt/ruby-jwt
  gem 'jwt', '~&gt; 2.2'
  
  gem 'devise'
  gem 'devise_token_auth'
  gem 'activerecord-session_store'　# Add
  </code></pre>
  <p><strong>Migaration</strong></p>
  <pre class="lang-rb prettyprint-override"><code>class AddSessionsTable &lt; ActiveRecord::Migration[6.0]
    def change
      create_table :sessions do |t|
        t.string :session_id, :null =&gt; false
        t.text :data
        t.timestamps
      end
  
      add_index :sessions, :session_id, :unique =&gt; true
      add_index :sessions, :updated_at
    end
  end
  </code></pre>
  <p><strong>config/initializers/session_store.rb</strong></p>
  <pre class="lang-rb prettyprint-override"><code>Rails.application.config.session_store :active_record_store,:key =&gt; '_my_app_session'
  </code></pre>