Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails ActiveRecord在使用oracle时为更新的\u抛出危险的AttributeError_Ruby On Rails_Oracle_Activerecord - Fatal编程技术网

Ruby on rails ActiveRecord在使用oracle时为更新的\u抛出危险的AttributeError

Ruby on rails ActiveRecord在使用oracle时为更新的\u抛出危险的AttributeError,ruby-on-rails,oracle,activerecord,Ruby On Rails,Oracle,Activerecord,我试图创建一个带有更新的时间戳的表,该表与rails兼容,但遇到了一些问题 我的创建表如下所示: create table cars ( id int not null, ... created_at date not null, updated_at date not null, constraint cars_id_pk primary key (id) ); class Car < ActiveRecord::Base end 相应的rails模型如下所示:

我试图创建一个带有更新的时间戳的表,该表与rails兼容,但遇到了一些问题

我的创建表如下所示:

create table cars (
  id int not null,
  ...
  created_at date not null,
  updated_at date not null,
  constraint cars_id_pk primary key (id)
);
class Car < ActiveRecord::Base
end
相应的rails模型如下所示:

create table cars (
  id int not null,
  ...
  created_at date not null,
  updated_at date not null,
  constraint cars_id_pk primary key (id)
);
class Car < ActiveRecord::Base
end
class-Car
当我尝试创建一个新模型时,我得到一个由ActiveRecord定义的
ActiveRecord::DangerousAttributeError:updated_at

如果我尝试
Car.instance\u method\u已经实现了?(:updated\u at)
这会抛出错误。当我执行
Car.instance\u method\u已经实现时(:created\u at)
它不会抛出错误

我发现另一件有趣的事情是在
上使用
updated\u可以很好地工作(以及在
上使用
created\u)

有人以前遇到过这个问题,或者对如何解决这个问题有什么想法吗


谢谢

您是如何设置模型的?您是否试图直接在
设置
updated\u的值?我不是,我希望能够使用传统的rails“魔法”,在创建或更新记录时,它会自动将
created/update\u设置为
。我想记录这些值。您能准确地显示您是如何更新模型记录以引发此错误的吗?这是在创建时发生的,不确定这是否有任何区别。相同的区别-创建时和更新时都在创建时设置。你能出示你的创建代码吗?