`next_migration_number':在轨道中使用wysihat-engine的NotImplementedError(NotImplementedError)

时间:2012-06-18 08:56:37

标签: ruby-on-rails wysihat

我正在使用以下gem作为编辑器。

gem "wysihat-engine", "~> 0.1.13"

当我运行'rails generate wysihat'时,它会生成所有图像文件,但无法生成迁移并发出以下错误

c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/generators/migration.rb:30:in `next_migration_number': NotImplementedError (NotImplementedError)
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/generators/migration.rb:49:in `migration_template'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/wysihat-engine-0.1.13/lib/generators/wysihat_generator.rb:60:in `install_wysihat'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `block in invoke_all'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `each'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `map'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/invocation.rb:124:in `invoke_all'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/group.rb:226:in `dispatch'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/thor-0.14.6/lib/thor/base.rb:389:in `start'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/generators.rb:170:in `invoke'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/generate.rb:12:in `<top (required)>'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
    from c:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:29:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

感谢您的帮助!

3 个答案:

答案 0 :(得分:5)

我刚刚使用Rails 4.1.5

来解决这个问题

我通过在迁移中实施

来修复它
class MigrationGenerator < ::Rails::Generators::Base
  include Rails::Generators::Migration

  def self.next_migration_number(dir)
    Time.now.utc.strftime("%Y%m%d%H%M%S")
  end
end

所以这有点像黑客。我找不到关于官方方式应该是什么的文件,或者为什么这甚至是一个问题。

答案 1 :(得分:0)

使用include ActiveRecord :: Generators :: Base代替。 (更新到宝石的最新版本可能有效。)

答案 2 :(得分:0)

require 'rails/generators/active_record'
class YourGenerator < ActiveRecord::Generators::Base
  # save you from `next_migration_number': NotImplementedError and undefined method `migration_template'
end