Skip to content

Instantly share code, notes, and snippets.

@stochastic-thread
Created June 11, 2015 18:51
Show Gist options
  • Save stochastic-thread/31368cfc308d2d094017 to your computer and use it in GitHub Desktop.
Save stochastic-thread/31368cfc308d2d094017 to your computer and use it in GitHub Desktop.
Setting @location
<script>
$.get("http://ipinfo.io", function(response) {
//console.log(response.loc);
var loc = response.loc;
console.log(response);
console.log(loc);
$.ajax({
url: 'store_temporary_user_location',
data: {"location": loc, "ip": response.ip},
type: "POST"
})
}, "jsonp");
</script>
<div class="panel panel-default">
<div class="feeds">
<div id="multigo" style="z-index: 400; border-radius: 10px 10px 10px 10px">
<div class="upperpart">
<span style="text-align: center"><p> People Around You</p></span>
<div class="lowerpart">
<% puts "CHECKPOINT" %>
<% puts @location %>
<% users = User.within(1, :origin => session[:location]) %>
<% users.each {|user| %>
<% puts user.name, user.lat_f, user.long_f %>
<% if user.dishes.length > 0 %>
<a class="users" style="margin: 5px 5px 5px 5px; color: #1565c0; text-decoration: none; opacity: 1.0" href="users/<%= user.id %>/show"> <%= user.name %> </a> </br>
<% end %>
<% } %>
</div>
</div>
</div>
<div id="livefeed" style="z-index: 390; border-radius: 10px 10px 10px 10px">
<div class="upperpart">
<span style="text-align: center"><p> Dishes Around You </p></span>
<div class="lowerpart">
<% users = User.within(1, :origin => @location) %>
<% users.each {|user| %>
<% dishes = user.dishes %>
<% dishes.each { |dish| %>
<% puts dish.name %>
<a style="margin: 5px 5px 5px 5px; text-decoration: none; color: #1565c0; opacity: 1.0" href="dishes/<%= dish.id %>"> <%= dish.name %> </a> </br>
<% } %>
<% } %>
</div>
</div>
</div>
</div>
</div>
post 'store_temporary_user_location' => 'users#temp_location'
def temp_location
puts "testing location"
a = params["location"].split(",")
@location = a.map {|x| x.to_f}
puts @location
@ip = params["ip"]
render 'pages/map2'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment