Browse files

Changed route assignments

  • Loading branch information...
1 parent bbb8523 commit fb67a02a1df22b566b21030b65463ba4cc8beb3c @semmin committed Mar 4, 2012
Showing with 10 additions and 8 deletions.
  1. +9 −7 app/controllers/buses_controller.rb
  2. +1 −1 app/views/buses/index.html.erb
View
16 app/controllers/buses_controller.rb
@@ -1,18 +1,20 @@
class BusesController < ApplicationController
def index
+ @buses = HrtBus::Bus.all
+ @buses.each do |bus|
+ if bus.route_id.blank?
+ ra = RouteAssignment.where(lat: bus.lat, lon: bus.lon).first
+ bus.route_id = ra.route_number if ra.present?
+ end
+ end
@buses = HrtBus::Bus.active_buses.select {|bus| bus.route_id == params[:route_id]}
+ @bus = @buses.last if @buses.present?
if @buses.blank?
flash[:notice] = "Sorry, no buses where found on the given route"
end
- @buses.each do |bus|
- File.new("./tmp/map_#{bus.id}.png", "w+") do |f|
- f.write(bus.static_map)
- f.save
- f.close
- end
- end
+
end
def show
View
2 app/views/buses/index.html.erb
@@ -124,7 +124,7 @@
</div>
<div data-role="content">
You should take bus <span id="routeNumber"></span> from <span id="startAddress"></span> toward <span id="busEndAddress"></span>.
- The bus is off by <%= @buses.last.adherence %> minutes.
+ The bus is off by <%= @bus.try(:adherence) %> minutes.
<div id="msg"></div>
<div id="mapcanvas" style="height: 200px; width: 200px;"></div>

0 comments on commit fb67a02

Please sign in to comment.