I’m trying to use the file_column plugin, and the upload portion of it
works
beautifully.
I’m trying to display the images now and I’m having a couple problems.
First is, when I try to use url_for_file_column, I get the following
error:
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.image_relative_path
The Code I’m using is this:
<% for photo in @photos %>
Second, I don’t know how to specify which version of the photo I
uploaded to
use.
I have a “thumb” and a “medium” and then the native size uploaded. How
do I
differentiate between the two?
I’m trying to display the images now and I’m having a couple problems.
First is, when I try to use url_for_file_column, I get the following error:
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.image_relative_path
This is because you need to have an instance variable and not a local
one:
<% for @photo in @photos %>
…
<% end %>
Second, I don’t know how to specify which version of the photo I uploaded to
use.
I have a “thumb” and a “medium” and then the native size uploaded. How do I
differentiate between the two?
url_for_file_column has a third parameter - version. If you leave it
off, you’ll get the original size, else you’ll get that named version.
“You have a nil object when you didn’t expect it!
The error occured while evaluating nil.image_relative_path”
You also get this or a similar error if the image field has not had a
path/filename set.
So you can either set a default value in the database, say
“/images/default.jpg” or do
image_tag url_for_file_column(“photo”, “image”) if @photo.image
Kris.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.