Hello: I defined a mehod in a model like this: def file=(file_field)#virtual attri is not same as access method unless file_field=="" #manage not upload image if file_field.content_type=~/^image/ && ensure_uniq_img("/images/users/"+file_field.original_filename) #the not image file will not be upload File.open("#{RAILS_ROOT}/public/images/users/#{file_field.original_filename}","wb") { |i| i.write(file_field.read)} end #show the error message self.photo="/images/users/"+file_field.original_filename end end
anyone can help me?
Is the form set to multipart ?
Fred
Frederick Cheung wrote:
who can help me?
My form codes are following:
<%form_tag :action=>"register",:method=>:post,:multipart=>true do-%> <%=render(:partial=>"changing_user",:object=>@user)-%> <%end-%>.
who can help me?
My form codes are following:
<%form_tag :action=>"register",:method=>:post,:multipart=>true do-%> <%=render(:partial=>"changing_user",:object=>@user)-%> <%end-%>.
who can help me?
That doesn't actually create a multipart form (check the html
generated).
When using form_tag like this, the first argument is the options used
to build the url to post to. The second parameter are the options for
the form itself, and this is where the multipart option does.
So you need something more like
<%form_tag( {:action=>"register"},:method=>:post,:multipart=>true) do-%>
<%form_tag( {:action=>"register"},:method=>:post,:multipart=>true) do-%>
Thank you.It is the brace that made the error.