Skip to content

Instantly share code, notes, and snippets.

@petitJAM
Created April 23, 2018 16:38
Show Gist options
  • Save petitJAM/f30af43c20fc681066d89c5c06faf8fc to your computer and use it in GitHub Desktop.
Save petitJAM/f30af43c20fc681066d89c5c06faf8fc to your computer and use it in GitHub Desktop.
Ruby constants in JavaScript
window.ProjectName.SomeModel = {}
window.ProjectName.SomeModel.SomeConstants = {}
<% SomeModel::SomeConstants.constants.each do |constant| %>
window.ProjectName.SomeModel.SomeConstants.<%= constant %> = "<%= SomeModel::SomeConstants.const_get(constant) %>"
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment