Ruby on rails 3 Rails Jquery使用remotipart gem NoMethodError上载文件:未定义的方法`name';
我正在使用gemremotipart上传文件。 以下是我的看法:Ruby on rails 3 Rails Jquery使用remotipart gem NoMethodError上载文件:未定义的方法`name';,ruby-on-rails-3,forms,file-upload,jquery-file-upload,remotipart,Ruby On Rails 3,Forms,File Upload,Jquery File Upload,Remotipart,我正在使用gemremotipart上传文件。 以下是我的看法: <%= form_for @file_upload, :id => "form_feedback_attachment", :url => { :controller => "widgets", :action => "feedback_attachment_upload" }, :html => {:multipart => true} do |f| %> <td cl
<%= form_for @file_upload, :id => "form_feedback_attachment", :url => { :controller => "widgets", :action => "feedback_attachment_upload" }, :html => {:multipart => true} do |f| %>
<td class="rightcol"><%= f.file_field :feedback_attachment, :id => "feedback_attachment_file" %>
<%= f.submit "Upload" %></td>
<% end %>
但我得到了这个错误:
NoMethodError:nil:NilClass的未定义方法“name”。我不知道方法名在哪里,来自哪个类。任何帮助都将不胜感激。乍一看,非常感谢-您没有将:remote=>设置为true,这是表单使用ajax所必需的,因此它应该是:
<%= form_for @file_upload, :remote => true, :id => "form_feedback_attachment", :url => { :controller => "widgets", :action => "feedback_attachment_upload" }, :html => {:multipart => true} do |f| %>
还要注意,我已经删除了第一行。希望这有帮助。{
<%= form_for @file_upload, :remote => true, :id => "form_feedback_attachment", :url => { :controller => "widgets", :action => "feedback_attachment_upload" }, :html => {:multipart => true} do |f| %>
if @file_upload
@file_upload.feedback_attachment = params[:file_upload][:feedback_attachment]
respond_to do |format|
if @file_upload.save
format.js
end
end
end