更新时间:2023-12-01 13:15:58
您可以覆盖 col_a
方法.使用 read_attribute
方法读取数据库中的值.像这样:
You can override the col_a
method. Use the read_attribute
method to read the value in database. Something like this:
def col_a
if self.read_attribute(:col_a).to_s.end_with?('0')
0
else
self.read_attribute(:col_a)
end
end