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| %>
Project name
<%= f.text_field :project_name %>
File name
<%= f.text_field :file_name %>
Sow
<%= f.text_field :sow_id %>
Workstmt
<%= f.file_field :workstmt %>
<%= f.submit "Create" %>
<% 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