Ruby 2.4 and Rails 4 stack level too deep (SystemStackError)
In Ruby 2.4, there was a unification of integer types (i.e. Fixnum
and Bignum
are now the very same thing: Integer
). This results on quite a few incompatibilities with existing gems which relied on the distinction of the classes.
Older versions of ActiveSupport are among those which don't like this unification and barf over it when trying to serialize data. As such, you have one of two options:
- You can downgrade Ruby to a version earlier than 2.4, e.g. Ruby 2.3.x.
- Or you could upgrade Rails to a newer version. Preferably, that could be Rails 5.x. There is also a patch in the 4.2-stable branch which was released with Rails 4.2.8, making it the first version of the Rails 4.2 series that officially supports Ruby 2.4. Earlier Rails versions are not compatible with Ruby 2.4.
in class:Numeric': stack level too deep (SystemStackError)
Install Rails 4.2.8, it's compatible with Ruby v 2.4.*
$ gem install rails -v '4.2.8'
How to fix the SystemStackError (stack level too deep) in rails model
In your code there is a before_create
callback that calls the remember
method. In this remember
method you call update_attribute
which internally tries to save
the record which calls the same before_create
callback.
To fix this just use a method to sets the remember_digest
attribute without triggering save
.
For example:
def remember
self.token = User.new_token
self.remember_digest = User.create_digest(token)
end
Related Topics
Difference Between Various Variables Scopes in Ruby
How to Use Ruby/Rails Variables Inside Sass
How to Use Ruby to Colorize the Text Output to a Terminal
Rails Sessions Current Practices
Rails: What's a Good Way to Validate Links (Urls)
Ruby'S File.Open and the Need For F.Close
How Does Object_Id Assignment Work
Suppress Ruby Warnings When Running Specs
Using Net::Http.Get For an Https Url
Find Indices of Elements That Match a Given Condition
How to Validate a Date in Rails
String Concatenation Vs. Interpolation in Ruby
Ssl_Connect Returned=1 Errno=0 State=Sslv3 Read Server Certificate B: Certificate Verify Failed