gpt4 book ai didi

postgresql - 使用 thumbs_up gem 的 Rails 迁移错误

转载 作者:行者123 更新时间:2023-11-29 11:52:57 24 4
gpt4 key购买 nike

我正在使用 thumbs_up gem 来创建投票系统。我正在使用 PostgreSQL。当我运行时:

rails generate thumbs_up

我收到以下错误:

/usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thumbs_up-0.6.7/lib/generators/thumbs_up/thumbs_up_generator.rb:21:in `create_migration': wrong number of arguments (3 for 0) (ArgumentError)
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/railties-4.0.4/lib/rails/generators/migration.rb:65:in `migration_template'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thumbs_up-0.6.7/lib/generators/thumbs_up/thumbs_up_generator.rb:22:in `create_migration'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/railties-4.0.4/lib/rails/generators.rb:156:in `invoke'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/railties-4.0.4/lib/rails/commands/generate.rb:11:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `block in require'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:214:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/activesupport-4.0.4/lib/active_support/dependencies.rb:229:in `require'
from /usr/local/rvm/gems/ruby-2.0.0-p247@firehose/gems/railties-4.0.4/lib/rails/commands.rb:48:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

我该如何解决这个问题?

最佳答案

这是 thumbs_up 中的错误。

在github上查看这个问题:https://github.com/bouchard/thumbs_up/issues/96

我偶然发现了同样的错误,并借助上面的链接修复了它。

显然,您所要做的就是更改 thumbs_up gem 中的文件(您会在错误本身中找到该 gem 的位置)。

在文件中[gem 路径]/lib/generators/thumbs_up/thumbs_up_generator.rb替换

def create_migration
migration_template 'migration.rb', File.join('db', 'migrate', 'thumbs_up_migration.rb')
end

def create_thumbs_up_migration
migration_template 'migration.rb', File.join('db', 'migrate', 'thumbs_up_migration.rb')
end

关于postgresql - 使用 thumbs_up gem 的 Rails 迁移错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23251109/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com