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