Hi,
url_for_file_column @variable, ‘name’, takes an instance variable. My
question is, what if I don’t want to have to retrieve the instance
variable
every single time but I have the image id, along with its name with me.
Could I contruct that object in a view and pass it to
url_for_file_column:
<% @picture = Picture.new %>
@picture.id = …
@picture.name = …
%>
and then pass @picture in? I tried this but when I tried the name
assignment, I got the following:
Do not know how to handle a string with value ‘somename.jpg’ that was
passed
to a file_column.
Thanks.
Sam D. wrote:
@picture.name <http://picture.name> = ...
%>
and then pass @picture in? I tried this but when I tried the name
assignment, I got the following:
Do not know how to handle a string with value ‘somename.jpg’ that was
passed to a file_column.
I’m pretty sure (away from devbox at the moment) that a file_column
field actually wants to be passed a FileIO (or StringIO, I think) object
so that it can handle the actual data.
In this case, you may well be better off either creating a mock class
that supports the methods that url_for_file_column requires (which I
think will be limited to name, id and class), or writing your own
helper to use instead of url_for_file_column.