1
我如何根據vehicle.vehicle_status
上一頁/下一頁鏈接基於模型的功能
在我的節目視圖中顯示一個/下一個環節:
- if @vehicle.previous
= link_to "< Previous", @vehicle.previous
- if @vehicle.next
= link_to "Next >", @vehicle.next
在我的模型:
def previous
?
end
def next
?
end
車/index.html.haml查看:
- @vehicles.each do |vehicle|
%tr
%td.dashbox{:class => vehicle.vehicle_status, :style =>'width:18px;', :onclick=>"top.location=#{vehicle_url(vehicle)}"}
個vehicle_status模型:
def vehicle_status
if self.maintenance_status=='c1' or self.fuel_efficiency_status=='c1' or self.system_status=='c1'
'c1'
elsif self.maintenance_status=='c2' or self.fuel_efficiency_status=='c2' or self.system_status=='c2'
'c2'
elsif self.maintenance_status=='c4' or self.fuel_efficiency_status=='c4' or self.system_status=='c4'
'c4'
else
'c3'
end
end
'嘗試沒有更新一block' – Bruno 2013-05-13 14:13:12
創建進程內對象 - 對不起爲 – PinnyM 2013-05-13 14:30:15
我再爛,用'reverse' - 不是'desc'。更新。 – PinnyM 2013-05-13 17:13:25