I'm trying to play around with my code and I have hit a
I have a script tag in an erb file. I get the browser timezone and store it in a constant. I want to use the value of the constant in a rails API method as an argument but I get the error
undefined local variable or method `browser_time_zone' for #
<script>
// this returns Eastern Time (US & Canada)
const browser_time_zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const timezone = <%= ActiveSupport::TimeZone::MAPPING.key(browser_time_zone) %>
</script>
How can I use the value of browser_time_zone as an argument to the TimeZone Mapping method? Any help will be appreciated