0
我有一個基本上有一堆布爾列的amenities模型。在導軌模型中過濾錯誤的列
我想在視圖中顯示真正的列,所以我想在模型級別過濾出錯誤的列。
我的初步想法:
# in model file
def available
a = {}
self.attributes.each do |key, value|
if value
a[key] = value
end
end
a
end
這是不完美的,因爲它給我的ID,created_at,和modified_at列。
我覺得必須有更好的方法來實現這一點。