I have one table called "posts" and two column lat/lng in sqlite. I just want to show it in leaflet map. I tried the loops each do

in testleaflet.html.erb

<% @posts.each do |post| %>
L.marker([<%=@post.lat%>,<%=@post.lng %>]).addTo(map);
<% end %>

Unfortunately I only see the last entered values(lat/lng) in the map. how can I do? thanks!

1 Answer 1

You need to change @post to post as you are lopping through @posts as post

<% @posts.each do |post| %>
  L.marker([<%=post.lat%>,<%=post.lng %>]).addTo(map);
<% end %>
    
Ok ... small distraction, now it's okay! – scofx 30 mins ago