I am using gem remotipart for uploading file. Here is my view:
<%= 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 %>
My controller:
@file_upload = FileUpload.new
@file_upload.feedback_attachment = params[:file_upload][:feedback_attachment]
respond_to do |format|
if @file_upload.save
format.js
end
end
But I get this error : NoMethodError: undefined method `name' for nil:NilClass. I have no idea from where is the method name and from which Class. Any help would be really appreciated. Thanks
At first glance - you have not set :remote => true, which is necessary for the form to work with ajax, so it should be:
At the controller, if you are using this action for something else this may be a problem, so you should wrap it like this:
Also note that i have removed the first line. Hope this helps. {: