新手问题 rails g wechat:session,出现以下提示,何处出了问题?

fengfans · 2019年09月01日 · 最后由 ericguo 回复于 2019年09月02日 · 2227 次阅读

rails 5.0.7+ruby 2.3.1+devise+wechat+omniauth-wechat-oauth2


/Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/generators/migration.rb:41:in `set_migration_assigns!': private method `next_migration_number' called for Wechat::Generators::SessionGenerator:Class (NoMethodError)
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/generators/migration.rb:57:in `migration_template'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/wechat-0.11.5/lib/generators/wechat/session_generator.rb:14:in `copy_wechat_sessions_migration'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `each'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `map'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/thor-0.20.3/lib/thor/invocation.rb:133:in `invoke_all'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/thor-0.20.3/lib/thor/group.rb:232:in `dispatch'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/generators.rb:180:in `invoke'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/commands/generate.rb:13:in `<top (required)>'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `require'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `block in require'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/activesupport-5.0.7.2/lib/active_support/dependencies.rb:293:in `require'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/commands/commands_tasks.rb:145:in `generate_or_destroy'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/commands/commands_tasks.rb:60:in `generate'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /Users/f/.rvm/gems/ruby-2.3.1@rails5new/gems/railties-5.0.7.2/lib/rails/commands.rb:18:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

看了下 wechat gem,应该是新版本的问题,三天前有个改动 https://github.com/Eric-Guo/wechat/commit/2a329cf4c269c7f17f2e20f4b81cdb94ea0cb69d#diff-ccb202bf88c8e17493a564aff1cc1e18L25

改动之后 next_migration_number 变成 private method 了,改动前的写法实际上 private 对 def self.next_migration_number 不起作用。rails generator 期待它是个 public method.

zhengpd 回复

谢谢,可以先直接改一下代码,我稍后会发个版修

version 0.11.6发布了,修了这个问题。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号