Another thought is that somewhere there
must be a controller that is responding to the image request. (we know
this because a controller/model is the only way to get something out of
the database, and you said that is where the images are stored)
hi, Starr T.
well, what I meant (and I was unclear) is that a referance name like
“test.jpeg” is stored there, and the actual file is stored in
“\public\entry\image\2”
where “2” matches the “id”.
There is a model responding to the image request, but no controller (the
controller only directs to the profile view (but is used to upload a
picture).
Yes, this is part of a plugin called “file_column”:
http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn
http://webonrails.wordpress.com/2006/06/22/plugin-file_column/
http://www.kanthak.net/opensource/file_column/#download
And the function “url_for_file_column” is a helper-function, like you
assumed.
The thing is that all of this works fine, with no problem at all, as
long as I don’t try “converting” it to “has_many” (and I thought that
would be an easy nut to crack). Silly me. There is not very much
documentation at all, but it was easy to implement and had got good
reviews so that’s why.
To make it clearer how it works for ONE image in the view (I made a
backup, luckily)
As you’ve seen before (my version with many):
<% @current_user.entries.each do |entry| %>
<%= image_tag url_for_file_column( “entry”, “image”) %>
<% end %>
What you said: “but I think the problem lies in using the string “entry”
rather then the local variable entry in that method call.”
You have gone through each image the user has and the record is assigned
to the local variable entry in the block, but no where in that block do
you make reference to that local variable, instead what I see is the
quoted string “entry.”
basically what I understood was that I didn’t use a referance to the
local variable entry.
and in the original (which worked) they make a referance “@entry”:
<% @entry = current_user.entry(params[:id]) %>
<%= image_tag url_for_file_column("entry", "image") %>
(but using this with “entries” instead “entry”… well it leaves another
error:
“You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.image_relative_path”)
thanks for your input, hopefully this will make it easier for you to
understand.