Я хочу передать переменные из контроллера в файл js. Вот что я делаю:Передача переменных в JS из контроллера Rails 4
#index.html.erb
<%= content_tag 'div', id: 'coords', data: { coords: @coords} do %>
<% end %>
#@coords is defined in maps#index
#@coords = Map.all
В консоли браузера я мог бы легко назвать:
$('#coords').data('coords')
# or to acces 1st object
$('#coords').data('coords')[0]
# or to acces its attribute
$('#coords').data('coords')[0].lat
#Object {id: 1, vibration_level: 456, lat: "71.45543", lon: "53.43424", time_sent: "1994-05-20T00:00:00.000Z"…}
Можете ли вы обновить воп вывод кода вида ? –