Url_for_file_column in parent model's view

Hi All,

I am using the file_column plugin to upload images. The model that I
am using is simply called images (id, name, caption - name being the
“file” column) and it belongs_to a parent model called books which
has_many images. I was able to figure out how to enter the images
into the correct model when updating of form of the parent model
(books). Now I need to figure out how to view the images in simple
display view of the parent model (books).

I am not sure about the syntax of the url_for_file_column helper.
Here is what I have so far:

<% for image in @book.images %>
Image:

<% url_for_file_column image, image.name, "thumb" %>

Caption

<%= image.caption %>

<% end %>

Which produces the following error:
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.image.name_relative_path

I also have a more general question about this function. How could
url_for_file_column figure out which model object (record) to display
if we are only to pass it the names of the model and relevant
attribute? Shouldn’t we have to pass it an ID as well?

Thanks,
Sean

Hi All,

I actually was able to get this to work after doing some more
searching. In case anyone else stumbles up this, there were two
problems with my code. First I used <% instead of <%= so nothing was
being output. Second, when iterating over an array you have to use <%
= image_tag url_for_file_column “image”, “name”, “thumb” %> instead
of just <%= url_for_file_column “image”, “name”, “thumb” %>

Sorry for the noise.

Sean

On 24-Jan-06, at 11:34 PM, Alien8 Recordings wrote:

I am not sure about the syntax of the url_for_file_column helper.
<% end %>
Thanks,
Sean


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails


ALIEN8 RECORDINGS
P.O. BOX 666, STATION R
MONTREAL, QC
CANADA, H2S 3L1

http://www.alien8recordings.com