I'm following the Heroku image upload tutorial which includes the following code in application.js -
fileInput.fileupload({
fileInput: fileInput,
url: '<%= @s3_direct_post.url %>',
type: 'POST',
autoUpload: true,
formData: <%= @s3_direct_post.fields.to_json.html_safe %>,
paramName: 'file', // S3 does not like nested name fields i.e. name="user[avatar_url]"
dataType: 'XML', // S3 returns XML if success_action_status is set to 201
replaceFileInput: false
});
...you can see that formData: does not have quotes around the erb - this is causing a javascript error when I deploy the code - SyntaxError: Unexpected token '<'
That erb should be in quotes, right? Any comment greatly appreciated.
application.jsis a static file (or rather 'quasi-static' because of the asset pipeline) and it won't be processed by erb. So even if you don't have JS syntax errors, it isn't gonna work./assets/javascripts/somejavascriptfile.js.erb- it's left me with other bugs, but this first one is solved, thank you.