我有这个表格
<%= form_for @post, :html => {:multipart => true , :class => 'form-horizontal' }, :remote => true do |f| %>
<%= f.text_field :title%>
<%= f.file_field :avatar%>
<%= f.submit nil%>
<% end %>
还有create
操作
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
format.js
end
end
end
无论我在 create.js.erb
中编写什么,它都不会运行,并且浏览器会重定向到白色页面!
$('body').html("<h1>Done!</h1>");
谁能告诉我这里出了什么问题吗? 请注意,我按照 github 上的文档示例步骤进行操作。
最佳答案
你应该确保
//= require jquery.remotipart
已添加到您的 application.js 文件中。我也遇到了同样的问题,这解决了它。
关于ruby-on-rails - 如何将Remotipart 1.0与Rails 3.2一起使用来保存文件上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11322424/