Assuming the script tag you mentioned is in a html erb view you can just use this:
<script type="text/javascript" charset="utf-8">
var json = <%= @json || 'null' %>;
</script>
More Related Contents:
- ExecJS::RuntimeError on Windows trying to follow rubytutorial
- JavaScript file per view in Rails
- Rails js.erb file cannot find method “render”
- Like button Ajax in Ruby on Rails
- rails and backbone working together
- How to translate a ‘greeting_for’ function from Ruby to Javascript [closed]
- Execute a command line binary with Node.js
- AngularJS- Login and Authentication in each route and controller
- Find DOM element by ID when ID contains square brackets?
- How do I use Mechanize to process JavaScript?
- Best way to add page specific JavaScript in a Rails 3 app?
- Object doesn’t support this property or method Rails Windows 64bit
- Why escape_javascript before rendering a partial?
- Find the longest common starting substring in a set of strings [closed]
- Uncaught ReferenceError: React is not defined
- Rails javascript only works after reload
- How to pass Ruby variables to a JavaScript function in a Rails view?
- How to get possibly overlapping matches in a string
- How can I change the title of the document during .ready()?
- How to pass a javascript variable into a erb code in a js view?
- Using a Rails helper method within a javascript asset
- Rails flash notice via ajax
- Rails: Webpacker 4.2 can’t find application in /app/public/packs/manifest.json heroku
- Rails, javascript not loading after clicking through link_to helper
- “Can’t find variable” error with Rails 3.1 and Coffeescript
- Single Page Application and CSRF Token
- Why “Prevent this page from creating additional dialogs” appears in the alert box?
- How to decrypt message with CryptoJS AES. I have a working Ruby example
- Rails 5/6: How to include JS functions with webpacker?
- Ruby on Rails – Send JavaScript variable from controller to external Javascript asset file