1
任何想法如何才能使其發揮作用?我不能爲我的生活弄清楚。Rails:訪問使用column_names選擇的列的值
def get_prices(c)
@print_prices = {}
Billing.where(:name => c).column_names.each do |d|
if d.match(/^print_/)
@print_prices[d] = d.value
end
end
return @print_prices
end
我不知道用什麼來代替d.value
。
乾杯任何幫助。
究竟是什麼你想在這裏做什麼? –
我正在嘗試構建值的散列,即'{「print_100」=>「30」,「print_200」=>「60」,「print_500」=>「90」}'。關鍵是列名,值是列的值。 –
你期望'Billing.where(:name => c)'只返回關係中的一條記錄嗎? –