I am trying to follow this example to embed Ruby code in my application.js How do I properly put embedded ruby code in to JavaScript?
However when I put the line:
var formData = <%= @s3_direct_post.fields.to_json.html_safe %>;
I get "SyntaxError: expected expression, got '<'"
I've seen advice on other similar questions to put quotes around the Ruby code like so:
var formData = '<%s3_direct_post.fields.to_json.html_safe %>';
but then the variable becomes the string <%s3_direct_post.fields.to_json.html_safe %>
instead of executing the Ruby and putting the result in a string.
FYI I'm following a tutorial (https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-rails) so it's possible that I didn't set something up right.