Guest User

Untitled

a guest
Aug 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. erb won't render in coffeescript file
  2. $ ->
  3. alert "Hello <%= @test %>"
  4. latlng = new google.maps.LatLng(43.0, -107.0);
  5. myOptions =
  6. zoom: 5,
  7. center: latlng,
  8. mapTypeId: google.maps.MapTypeId.ROADMAP
  9. map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  10. point = new google.maps.LatLng(43.0, -107.0);
  11. marker = new google.maps.Marker({
  12. position: point,
  13. map: map,
  14. title: "Test",
  15. });
  16.  
  17. class LocationsController < ApplicationController
  18.  
  19. def show
  20. @traveling_party = TravelingParty.find_by_id(session[:party])
  21. @location = Location.where("position >= #{@traveling_party.position}").order("position ASC").first
  22. end
  23.  
  24. def move
  25. f = params[:traveling_party]
  26.  
  27. @traveling_party = TravelingParty.find(f["id"])
  28. @traveling_party.speed = f["speed"].to_i
  29. @traveling_party.ration = f["ration"].to_i
  30.  
  31. @location = Location.where("position > #{@traveling_party.position}").order("position ASC").first
  32.  
  33. @traveling_party.position += @traveling_party.speed
  34. if @traveling_party.position > @location.position
  35. @traveling_party.position = @location.position
  36. end
  37.  
  38. food_eaten = @traveling_party.ration * @traveling_party.people
  39. Item.where({:trader_id => @traveling_party.id, :type => "Food"}).limit(food_eaten).destroy_all()
  40.  
  41. if @traveling_party.save()
  42. flash[:notice] = "Successfully updated traveling party."
  43. redirect_to '/play/'
  44. else
  45. flash[:error] = "Transaction could not be completed."
  46. redirect_to '/play/'
  47. end
  48. end
  49.  
  50. def map
  51. @traveling_party = TravelingParty.find_by_id(session[:party])
  52. @locations = Location.all
  53. @test = "5"
  54. end
  55.  
  56. end
  57.  
  58. <% @locations.each do |loc| %>
  59.  
  60. <% end %>
  61.  
  62. <div id="map_canvas">Random</div>
Add Comment
Please, Sign In to add comment