Ruby on rails Rails迁移错误:参数数目错误
我刚刚克隆了一个存储库,所以我试图在本地进行设置,每当我运行Ruby on rails Rails迁移错误:参数数目错误,ruby-on-rails,ruby,activerecord,migration,Ruby On Rails,Ruby,Activerecord,Migration,我刚刚克隆了一个存储库,所以我试图在本地进行设置,每当我运行rails db:migrate时,我都会遇到这个奇怪的错误,我已经搜索了一个解决方案,但这里没有一个能满足我的需要 我对此感到特别困惑,因为这是我第一次使用rails 6.0,我无法判断这是rails的问题还是代码中有什么错误,尽管在跟踪之后,问题似乎与时间戳类型有关,但我不知道该怎么办 错误 t.timestamp不接受时间戳名称,只接受散列/关键字参数: 时间戳(选项={}) 将时间戳(在处创建)和在处更新)列添加到表中 t.时间
rails db:migrate
时,我都会遇到这个奇怪的错误,我已经搜索了一个解决方案,但这里没有一个能满足我的需要
我对此感到特别困惑,因为这是我第一次使用rails 6.0,我无法判断这是rails的问题还是代码中有什么错误,尽管在跟踪之后,问题似乎与时间戳类型有关,但我不知道该怎么办
错误
t.timestamp
不接受时间戳名称,只接受散列/关键字参数:
时间戳(选项={})
将时间戳(在
处创建)和在
处更新)列添加到表中
t.时间戳(null:false)
如果要在添加expires\u,则需要使用正确的日期类型(例如,datetime
):
class CreateProjects < ActiveRecord::Migration[5.0]
def change
create_table :projects do |t|
# ...
t.datetime :expires_at
end
end
end
class CreateProjects
t.timestamps
不接受时间戳名称,只接受哈希/关键字参数:
时间戳(选项={})
将时间戳(在
处创建)和在
处更新)列添加到表中
t.时间戳(null:false)
如果要在
添加expires\u,则需要使用正确的日期类型(例如,datetime
):
class CreateProjects < ActiveRecord::Migration[5.0]
def change
create_table :projects do |t|
# ...
t.datetime :expires_at
end
end
end
class CreateProjects
是t.timestamps:expires\u在第8行?(看起来是这样。)t.timestamps:expires\u在是什么?也许应该是t.datetime:expires\u在
?谢谢,很多人,这很有帮助,我改为datetimeIst.timestamps:expires\u在第8行?(看起来是这样。)什么是t.timestamps:expires\u at
?也许应该是t.datetime:expires\u at
?谢谢大家,这很有帮助,我改成了datetime
/home/noriodebrume/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sprockets-3.6.3/lib/sprockets/digest_utils.rb:47: warning: constant ::Fixnum is deprecated
/home/noriodebrume/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sprockets-3.6.3/lib/sprockets/digest_utils.rb:51: warning: constant ::Bignum is deprecated
/home/noriodebrume/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sprockets-3.6.3/lib/sprockets/processor_utils.rb:110: warning: constant ::Fixnum is deprecated
/home/noriodebrume/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sprockets-3.6.3/lib/sprockets/processor_utils.rb:111: warning: constant ::Bignum is deprecated
class CreateProjects < ActiveRecord::Migration[5.0]
def change
create_table :projects do |t|
# ...
t.datetime :expires_at
end
end
end