に従って前/次のリンクを表示するにはどうすればよいですか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
vehicle/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