Search code examples
ruby-on-railsmongoid

Mongoid::Criteria can't modify frozen String


This perplexes me. A Mongoid::Criteria is not frozen, but if I assign it to a variable in console, it tells me FrozenError (can't modify frozen String: "#<Mongoid::Criteria

Why would that be, and how do I fix it?

mongoid (~> 7.3.0) rails (~> 6.0.0)

enter image description here


Solution

  • I found this issue in IRB repo: https://github.com/ruby/irb/issues/136. It means the issue was fixed in a later version of IRB, so my suggestion is to force IRB version higher than 2.8 to get the fix.

    Just add gem 'irb', '>= 1.2.8' to your gemfile and test that it works with your current Ruby version.