Navjeet Chabbewal
2006-Apr-23 00:37 UTC
[Rails] file_column does not work with update model
When I am creating a model, everything works but not during update (where I use Model.update_attributes(model_attributes) ). I get the error: Do not know how to handle a string with value ''image_xxx.jpg'' that was passed to a file_column. Check if the form''s encoding has been set to ''multipart/form-data''. The form is indeed multipart. Does file_column work with update_attributes? In the server log I see message: script/server: No such file or directory - file -bi "./script/../config/../publi c/temple/image1/tmp/1145739576.129000.3652/image_xxx.JPG" but the image is there in /public/temple/image1/tmp/1145739576.129000.3652/ folder. What could be going wrong here? -- Posted via http://www.ruby-forum.com/.
Navjeet Chabbewal
2006-Apr-23 06:18 UTC
[Rails] Re: file_column does not work with update model (FIXED)
The problem has to do with my update method in the controller. I was doing a find_by_id in my update and then setting the attributes. This was followed later by call to update_attributes like below: def update @temple = Temple.find(params[:id]) @temple.attributes = params[:temple] ... ... ... @temple.update_attributes(@temple.attributes) end If I take out the call to @temple.attributes = params[:temple] and replace it with @temple.update_attributes(params[:temple) things are working. So seems like I need to rework my update method impl. Navjeet Chabbewal wrote:> When I am creating a model, everything works but not during update > (where I use Model.update_attributes(model_attributes) ). > I get the error: > > Do not know how to handle a string with value ''image_xxx.jpg'' that was > passed to a file_column. Check if the form''s encoding has been set to > ''multipart/form-data''. > > The form is indeed multipart. Does file_column work with > update_attributes? In the server log I see message: > > script/server: No such file or directory - file -bi > "./script/../config/../publi > c/temple/image1/tmp/1145739576.129000.3652/image_xxx.JPG" > > but the image is there in > /public/temple/image1/tmp/1145739576.129000.3652/ folder. > > What could be going wrong here?-- Posted via http://www.ruby-forum.com/.