title: How to get ActiveRecord non-persistant variable to save?
body: <p>I'm trying to setup an attribute that isn't saved to the database but I can't work out how to change it and read the new value.</p>
  
  <pre><code>class User &lt; ApplicationRecord
    attribute :online, :boolean, default: false
  end
  </code></pre>
  
  <p>in Rails Console:</p>
  
  <pre><code>User.first.online = true
  =&gt; true
  User.first.online
  =&gt; false
  </code></pre>
  
  <p>I'm running Ruby-on-rails 5.2.4.1 and ruby 2.4.1
  <a href="https://api.rubyonrails.org/v5.2.4.1/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute" rel="nofollow noreferrer">https://api.rubyonrails.org/v5.2.4.1/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute</a></p>