[Rails] file column inserts wrong file url field into database

Amin Salahuddin
2006-03-27T03:59:30Z

Hello,
ive set up file column like so

Controller:

def entry
    @entry = Entry.new(@params[:entry])
        if @entry.save
          flash[:notice] = ''Product was successfully updated.''
        else
         flash[:notice] = ''?''
        end
      end

Model:

file_column :image



View:

<%= form_tag({:action=>''entry'', :id=> @entry },
:multipart => true)%>
<%= file_column_field "entry", "image" %>
 <%= submit_tag ''entry'' %>
<%=  end_form_tag %>


It seems like when the form is submitted it commits the hidden
"image_temp" part of the multipart form instead of the
"file" part.

and this is what happens.:

 Parameters: {"commit"=>"Upload",
"action"=>"entry",
"controller"=>"entry",
"entry"=>{"image_temp"=>"",
"image"=>#<File:/tmp/CGI22011.1>}}

  SQL    BEGIN
  SQL   INSERT INTO entries (`entry`, `image`) VALUES(NULL,
''ihavebeenthinkingaboutyoual.gif'')
  SQL    COMMIT

so i end up with  null value for my entry object.


funny thing is if i put this in the entry view:
 <%=image_tag url_for_file_column "entry", "image"  %>
while submiting it from another .rhtml file, i get a correct path and
the image shows up. acutally the image uploads perfectly but the url
reference does not make it to the database.

im new to rails so im not exactly sure how to tackle this.
any help will be greatly appreciated.
THANKS.

--
Posted via http://www.ruby-forum.com/.