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 %> <tr> <td><%= image_tag url_for_file_column("photo", "image") %></td> <td><%=h item.name %></td> <td><%=h item.description %></td> <td><%= link_to ''Show'', :action => ''show'', :id => item %></td> <td><%= link_to ''Edit'', :action => ''edit'', :id => item %></td> <td><%= link_to ''Destroy'', { :action => ''destroy'', :id => item }, :confirm => ''Are you sure?'' %></td> </tr> <% 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? Any help is appreciated, Thanks, BJ Clark _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Hi ! 2005/12/1, BJ Clark <scidept@gmail.com>:> 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_pathThis 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. Hope that helps ! -- François Beausoleil http://blog.teksol.info/ _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Works beautifully! Thanks, BJ Clark On 12/1/05, Francois Beausoleil <francois.beausoleil-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi ! > > 2005/12/1, BJ Clark <scidept-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > 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. > > Hope that helps ! > -- > François Beausoleil > http://blog.teksol.info/ > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
"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. BJ Clark wrote:> 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 %> > <tr> > > <td><%= image_tag url_for_file_column("photo", "image") %></td> > > <td><%=h item.name <http://item.name> %></td> > > <td><%=h item.description %></td> > > <td><%= link_to ''Show'', :action => ''show'', :id => item %></td> > > <td><%= link_to ''Edit'', :action => ''edit'', :id => item %></td> > > <td><%= link_to ''Destroy'', { :action => ''destroy'', :id => item }, > :confirm => ''Are you sure?'' %></td> > > </tr> > > <% 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? > > Any help is appreciated, > Thanks, > BJ Clark > >------------------------------------------------------------------------ > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > >