Guest User

Untitled

a guest
Jun 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. def create
  2. begin
  3. @link = Link.find(params[:id])
  4. @outlet = Outlet.find(@link.outlet.id)
  5. @address= @outlet.address
  6. @floorplan = Floorplan.find_by_floor_id_and_is_active(@address.floor,true)
  7.  
  8. if @floorplan.nil?
  9. render :action => :upload
  10. else
  11.  
  12. @all_outlets = Outlet.find_all_by_address_id(@address)
  13. @Coords, @unplaced_outlets = @all_outlets.partition(&:x)
  14.  
  15. @temp = Address.find_all_by_floor_id(@address.floor_id)
  16.  
  17. rooms = {}
  18. for r in @temp
  19. rooms[r] = Room.find(r.room_id).name
  20. end
  21. @rooms = rooms.values
  22. @rooms = @rooms.sort
  23.  
  24. @ports = {}
  25. @switches = {}
  26. for o in @Coords
  27. link = Link.find_by_outlet_id(o.id)
  28. unless link.nil?
  29. @ports[o] = Port.find(link.port_id)
  30. @switches[o] = Switch.find(@ports[o].switch_id)
  31. end
  32. end
  33.  
  34. render :action => :index
  35. end
  36.  
  37. rescue Exception #exception, probably caused by attempting to view a floorplan other than from the search results button
  38. flash[:notice] = "Error viewing floorplan. redirected to search results"
  39. redirect_to :controller => search, :action => :new
  40. end
  41. end
Add Comment
Please, Sign In to add comment