railsのバージョンは4.1.6でした。
こんな感じのmodelを作っていました。
class Sample < ActiveRecord::Base enum target: { all_user: 0, parent: 1, } end
そして動かしてみようとすると、エラーが出ました。
irb(main):001:0* aaa = Sample.new SystemStackError: stack level too deep from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/scoping.rb:68:in `value_for' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activesupport-4.1.6/lib/active_support/per_thread_registry.rb:47:in `public_send' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activesupport-4.1.6/lib/active_support/per_thread_registry.rb:47:in `block in method_missing' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/scoping.rb:14:in `current_scope' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/scoping/named.rb:25:in `all' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/scoping/named.rb:151:in `block in scope' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/model_schema.rb:335:in `compute_table_name' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/model_schema.rb:148:in `reset_table_name' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/model_schema.rb:109:in `table_name' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/core.rb:151:in `arel_table' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/core.rb:167:in `relation' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/scoping/named.rb:33:in `default_scoped' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/scoping/named.rb:28:in `all' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/scoping/named.rb:151:in `block in scope' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/model_schema.rb:335:in `compute_table_name' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activerecord-4.1.6/lib/active_record/model_schema.rb:148:in `reset_table_name' ... 10760 levels... from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `block in load' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:241:in `load' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `call' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/command_wrapper.rb:38:in `call' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:191:in `block in serve' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:161:in `fork' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:161:in `serve' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/application.rb:125:in `run' from /Users/xxx/Documents/github/test/vendor/bundle/ruby/2.3.0/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `' from /Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/xxx/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from -e:1:in ` '
調べてみると、enumには使ってはいけない単語を使ってるけど、
それをチェックしてないから起こっているエラーのようです。
すでに修正されていて、rails4.2からはSystemStackErrorではなく、
conflictしてるとわかるエラーが出るようです
参考URL
https://github.com/rails/rails/issues/16347
https://github.com/rails/rails/commit/94b7328b08fcc55e82bfcaa34a25ae718921ae1c
0 件のコメント:
コメントを投稿