以前用过rails-settings-cached这个神器去管理网站设置的参数,非常好用,也没碰到过问题。
这次的新项目是基于 rails5.1,gem 安装以后,按照文档中的提示执行命令rails g settings:install
,提示以下错误信息:
[user1@mac1 demo1 (master)]$ rails g settings:install
[WARNING] Could not load generator "generators/settings/install_generator". Error: Settings is not a module.
/Users/user1/.rvm/gems/ruby-2.4.2/gems/rails-settings-cached-0.6.6/lib/generators/settings/install_generator.rb:4:in `<top (required)>'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/command/behavior.rb:82:in `block (2 levels) in lookup'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/command/behavior.rb:78:in `each'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/command/behavior.rb:78:in `block in lookup'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/command/behavior.rb:77:in `each'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/command/behavior.rb:77:in `lookup'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/generators.rb:250:in `find_by_namespace'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/generators.rb:267:in `invoke'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/commands/generate/generate_command.rb:24:in `perform'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
/Users/user1/.rvm/gems/ruby-2.4.2/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'
Could not find generator 'settings:install'. Maybe you meant 'config:install', 'test_unit:system' or 'scss:assets'
Run `rails generate --help` for more options.
搜索了网上,发现有人报告过同样的错误,后来华顺没有跟进了:https://github.com/huacnlee/rails-settings-cached/issues/54。
有人怀疑settings
在新版本的 rails 中是保留关键字了,所以需要将模块改名称。请指教如何解决这个问题。谢谢!!