This is the controller code that will work (with workstmt_file) being
the name of the file_field comng from the form
@workstmt = Workstmt.new
@workstmt.file_name = params[:workstmt]
[:workstmt_file].original_filename
@workstmt.content_type = params[:workstmt]
[:workstmt_file].content_type
@workstmt.workstmt = params[:workstmt][:workstmt_file].read
On Jun 10, 12:07 pm, Jorg Lueke
<jlueke_2...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
wrote:> I''m a data person and some of the basics on the front end seem to
> escape me. I am merely trying to upload a file to the backend.
> Everything works except that what is uploaded is not the file but the
> reference to the file, i.e. #<File:0x57d79b8>
>
> It''s got to be a simple thing I am missing...
>
> This is the form
>
> <% form_for(@workstmt,:url=>{:action=>''create''},
> :html => {:multipart=>true}) do |f| %>
> <p>
> <b>Project name</b><br />
> <%= f.text_field :project_name %>
> </p>
>
> <p>
> <b>File name</b><br />
> <%= f.text_field :file_name %>
> </p>
>
> <p>
> <b>Sow</b><br />
> <%= f.text_field :sow_id %>
> </p>
>
> <p>
> <b>Workstmt</b><br />
> <%= f.file_field :workstmt %>
> </p>
>
> <p>
> <%= f.submit "Create" %>
> </p>
> <% end %>
>
> and the controller snippet is the default from the scaffold
>
> def create
> @workstmt = Workstmt.new(params[:workstmt])
> respond_to do |format|
> if @workstmt.save
> flash[:notice] = ''Workstmt was successfully
created.''
> format.html { redirect_to(@workstmt) }
> format.xml { render :xml => @workstmt, :status
> => :created, :location => @workstmt }
> else
> format.html { render :action => "new" }
> format.xml { render :xml => @workstmt.errors, :status
> => :unprocessable_entity }
> end
> end
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---