我收到错误的URI错误。我假设uri是通过S3_uploader函数形成的。我能够上传到s3服务器,但代码在到达我的视图/模型之前停止执行,并且没有数据存储在数据库中。我在下面的视图和.js文件中发布了代码。我意识到[object%20Object]是因为尝试将{}转换为字符串而产生的,但是从我的代码中删除它们并不会更改错误消息。有人可以帮助我了解这里的问题(uri正在形成的地方)以及我如何解决这个问题?我已经坚持了一段时间。非常感谢。
错误:
[2015-02-21 11:44:42] ERROR bad URI `/bands/1/[object%20Object]'. (Console)
[Error] Failed to load resource: the server responded with a status of 400
(Bad Request) ([object Object], line 0) (Safari dev window)
使用Javascript:
var ready;
alert("Hello");
ready = function() {
$(function() {
$('#s3_uploader').S3Uploader(
{
remove_completed_progress_bar: true,
progress_bar_target: $('#uploads_container')
}
);
$('#s3_uploader').bind('s3_upload_failed', function(e, content) {
return alert(content.filename + ' failed to upload');
});
});
};
$(document).ready(ready);
$(document).on('page:load', ready);
乐队视图
<%= s3_uploader_form callback_url: bands_url,
id: "s3_uploader",
callback_param: "song[direct_upload_url]",
expiration: 24.hours.from_now.utc.iso8601,
max_file_size: 100.megabytes do %>
<%= file_field_tag :file, multiple: true %>
<% end %>
<div id="uploads_container"></div>
<script id="template-upload" type="text/x-tmpl">
<div id = "upload_{%=o.unique_id%}" class="upload">
<h5>{%=o.name%}</h5>
<div class="progress progress-striped active"><div class="bar" style="width: 0%"></div></div>
</div>
</script>