一直遵循rails指南,同时运行代码
rails generate model Comment commenter:string body:text article:reference
我收到以下错误
/Users/Developer/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1/lib/active_record/dynamic_matchers.rb:22:in
method_missing':未定义的方法whitelist_attributes=' for ActiveRecord::Base:Class (NoMethodError)
曾尝试搜索类似的问题,而一项建议是删除
config.active_record.whitelist_attributes = false
已搜索了整个应用目录,找不到任何此类代码。
轨道版本:5.2.1 Ruby版本:2.5.1
$ bundle exec rails generate model Comment
config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:
* development - set it to false
* test - set it to false (unless you use a tool that preloads your test environment)
* production - set it to true
invoke active_record
Traceback (most recent call last):
49: from script/rails:6:in `<main>'
48: from script/rails:6:in `require'
47: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<top (required)>'
46: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
45: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
44: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
43: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
42: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
41: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/commands/generate/generate_command.rb:26:in `perform'
40: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/generators.rb:276:in `invoke'
39: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
38: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/group.rb:232:in `dispatch'
37: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `invoke_all'
36: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `map'
35: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `each'
34: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `block in invoke_all'
33: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
32: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
31: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/group.rb:133:in `_invoke_from_option_orm'
30: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/group.rb:266:in `_invoke_for_class_method'
29: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/shell.rb:68:in `with_padding'
28: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/group.rb:277:in `block in _invoke_for_class_method'
27: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:115:in `invoke'
26: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/group.rb:232:in `dispatch'
25: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `invoke_all'
24: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `map'
23: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `each'
22: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:133:in `block in invoke_all'
21: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
20: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
19: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1/lib/rails/generators/active_record/model/model_generator.rb:22:in `create_migration_file'
18: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/generators/named_base.rb:92:in `table_name'
17: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/railties-5.2.1/lib/rails/generators/named_base.rb:201:in `pluralize_table_names?'
16: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
15: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:253:in `load_dependency'
14: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `block in require'
13: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/dependencies.rb:287:in `require'
12: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1/lib/active_record/base.rb:27:in `<top (required)>'
11: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1/lib/active_record/base.rb:328:in `<module:ActiveRecord>'
10: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
9: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
8: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
7: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:67:in `execute_hook'
6: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:62:in `with_execution_control'
5: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
4: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activesupport-5.2.1/lib/active_support/lazy_load_hooks.rb:71:in `instance_eval'
3: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1/lib/active_record/railtie.rb:123:in `block (2 levels) in <class:Railtie>'
2: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1/lib/active_record/railtie.rb:123:in `each'
1: from /Users/Developer/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1/lib/active_record/railtie.rb:124:in `block (3 levels) in <class:Railtie>'
/Users/Developer/.rvm/gems/ruby-2.5.1/gems/activerecord-5.2.1/lib/active_record/dynamic_matchers.rb:22:in `method_missing': undefined method `whitelist_attributes=' for ActiveRecord::Base:Class (NoMethodError)