I think I am doing something simply boneheaded but I don''t see it. I
hope you are willing to take a look:
I am simply wanting to upload a file and hand the file in my controller
to some code that will process it. It is not getting stored.
The UI is a "maintain" page with a file entry field in a form, and a
button to import the file and some other maintenance tasks which are not
relevant right now.
Here are snippets:
routes.rb:
map.maintain ''/maintain/import_file'', :controller =>
''maintain'',
:action => ''import_file'', :conditions => { :method =>
:put }
map.maintain ''/maintain/export_file'', :controller =>
''maintain'',
:action => ''export_file'', :conditions => { :method =>
:put }
map.maintain ''/maintain/:action'', :controller =>
''maintain''
notes: I know this is too verbose, it''s been my attempt to trouble
shoot. I don''t believe this should be a resource route given that its a
maintenance page. But I could be wrong about that.
index.html.erb:
What would you like to maintain?
<ul>
<li>Import for bulk Election load
<p>
<% form_tag :action => ''import_file'', :method
=> ''put'', :multipart
=> true do %>
<%= file_field_tag "importFile", :accept =>
"text/xml" %>
<br>Import as:
<%= submit_tag "XML file" %>
<%= submit_tag "YML file" %>
<% end %>
</p>
</li>
notes: There are two buttons in this form, one to import it from an XML
file and one from a YML file. Is that somehow making it sick?
maintain_controller.rb:
def import_file
begin
if params[:importFile].nil?
flash[:error] = "Yes: Import failed because file was not
specified."
redirect_to :back
[...] snip
Notes: when I break here, params[:importFile] is a text string with the
file name, NOT a File:: object. Also the url looks like this:
http://localhost:3000/maintain/import_file?method=put&multipart=true
which is not what I expected.
Thanks for spending a few minutes with me on this, if possible!!
Pito Salas
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.