虽然我在其他博客中看到了这个问题,但我无法让它适用于我的情况。我的观点:
<%= semantic_form_for :routes_status_race, :url => status_race_admin_routes_path do |f| %>
<% contact_array = Contact.all.map {|contact| [contact.name, contact.id]}%>
<% route_importer_array = RouteImporter.all.map {|importer| [importer.name, importer.id]}%>
<%= f.inputs do%>
<%= f.input :contact, :as => :select, :collection => Contact.all %>
<%= f.input :route_import, :as => :select, :collection => RouteImporter.all %>
<%= f.input :uploaded_data, :action => :status_race, :multipart => true, :as => :file %>
<%end%>
<input name='commit' type='submit' method='post' value='Import'/>
<%end%>
我的控制器:
collection_action :status_race, :method => :post do
uploaded_io = params[:uploaded_data].original_filename
File.open(Rails.root.join('app/importers', 'uploads', uploaded_io.original_filename), 'w') do |file|
file.write(uploaded_io.read)
end
RoutesQuickcom.new.run(uploaded_io.original_filename)
render "status_race"
end
我收到此错误:我的控制器中的 nil:NilClass 的未定义方法“original_filename”,我不知道如何修复它,任何帮助将不胜感激,谢谢!