什么是使我的表列成为只读的最佳方法?禁用setter方法?该列由postgres触发器设置,所以我不想在应用程序级别设置它
i1icjdpr1#
您似乎在寻找ActiveRecord::Base attr_readonly:
attr_readonly
class Foo < ActiveRecord::Base attr_readonly :bar end foo = Foo.create(bar: "first_value") foo.bar => "first_value" foo.update(bar: "second_value") #column `bar` ignored in SQL query foo.bar => "first_value"
1条答案
按热度按时间i1icjdpr1#
您似乎在寻找ActiveRecord::Base
attr_readonly
: