假设我有一个Dog
,我想在Rails中存储它是否为trained
.Ruby方法通常有?
个布尔值.Should I call the database column 103, or should I call the database column 101 and have a method
class Dog
def trained?
trained
end
end
后一个选项似乎效率低下,尤其是当我有很多布尔字段时.
还是我还缺少其他的 Select ?
假设我有一个Dog
,我想在Rails中存储它是否为trained
.Ruby方法通常有?
个布尔值.Should I call the database column 103, or should I call the database column 101 and have a method
class Dog
def trained?
trained
end
end
后一个选项似乎效率低下,尤其是当我有很多布尔字段时.
还是我还缺少其他的 Select ?
你应该叫它trained
.在模式中使用:boolean
类型定义它.你可以把它称为trained?
,一切都会神奇地工作.