This is an app in rails.
Here's what I have in 'routes':
resources :destinations
Here is what I have in 'destinations_controller':
def show
@destination = Destination.find(params[:id])
end
Here's what I have in 'views/destinations/show.html.erb':
<h2><%= @destination.latitude %></h2>
<script>
var dest_lat = <%= @destination.latitude %>
</script>
Here's what I have in 'application.js':
var dest_location = {dest_lat};
This is the third time I've built this app. Initially, I get no errors and all the coding works fine... for a few hours. Then, without me changing anything, the value in @destination.latitude still appears in the h2 tag, but I start to receive the error:
Uncaught ReferenceError: dest_lat is not defined
with a link that shows its use in 'application.js', and the app ceases to work.
Why?
Any help is appreciated.
@destination.latitudeis not outputting anything.