如何根据以下内容显示上一个/下一个链接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)}"}
模型中的车辆状态:
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