Forum: Ruby on Rails file_column does not work with update model

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
74a56286718bc003d6c7438f7efa1e3a?d=identicon&s=25 Navjeet Chabbewal (jeet)
on 2006-04-23 02:37
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?
74a56286718bc003d6c7438f7efa1e3a?d=identicon&s=25 Navjeet Chabbewal (jeet)
on 2006-04-23 08:18
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?
This topic is locked and can not be replied to.