I am using the very helpful file_column extension in my app. The uploading portion works great - no problems. Where I am having an issue is displaying the images in my view. My code looks like this: <% for @record in @main_box_releases -%> <%= image_tag(url_for_file_column("record", "record_cover")) %> <% end -% @record is an instance of a class called Release. It is not nil, removing the url_for_file_column makes all errors go away and other calls to @record complete just fine. I get this error: cannot convert nil into String I''ve tried many variations, such as: url_for_file_column(:record, "record_cover") url_for_file_column("release", "record_cover") url_for_file_column(@record, "record_cover") Nada on any of them. What am I doing wrong? Thanks, Hunter
I am using the very helpful file_column extension in my app. The uploading portion works great - no problems. Where I am having an issue is displaying the images in my view. My code looks like this: <% for @record in @main_box_releases -%> <%= image_tag(url_for_file_column("record", "record_cover")) %> <% end -% @record is an instance of a class called Release. It is not nil, removing the url_for_file_column makes all errors go away and other calls to @record complete just fine. I get this error: cannot convert nil into String I''ve tried many variations, such as: url_for_file_column(:record, "record_cover") url_for_file_column("release", "record_cover") url_for_file_column(@record, "record_cover") Nada on any of them. What am I doing wrong? Thanks, Hunter
Hi Hunter, Try: <%= image_tag url_for_file_column("record", "record_cover") rescue nil %> Note the rescue nil on the end - I was having the same problem you were and several on the list recommended adding the rescue nil and it worked like a charm. Brent --- Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote:> I am using the very helpful file_column extension in > my app. > > The uploading portion works great - no problems. > > Where I am having an issue is displaying the images > in my view. My code > looks like this: > > <% for @record in @main_box_releases -%> > > <%= image_tag(url_for_file_column("record", > "record_cover")) %> > > <% end -% > > @record is an instance of a class called Release. It > is not nil, removing > the url_for_file_column makes all errors go away and > other calls to @record > complete just fine. > > I get this error: > > cannot convert nil into String > > I''ve tried many variations, such as: > url_for_file_column(:record, "record_cover") > url_for_file_column("release", "record_cover") > url_for_file_column(@record, "record_cover") > > Nada on any of them. What am I doing wrong? > > Thanks, > Hunter > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Yahoo! Music Unlimited Access over 1 million songs. Try it free. http://music.yahoo.com/unlimited/
That works like a charm! Thanks for the tip.> From: Brent Beardsley <brentbeardsley-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > Reply-To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Date: Mon, 10 Oct 2005 11:22:07 -0700 (PDT) > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Subject: Re: [Rails] Problem With url_for_file_column/file_column > > Hi Hunter, > > Try: > > <%= image_tag url_for_file_column("record", > "record_cover") rescue nil %> > > Note the rescue nil on the end - I was having the same > problem you were and several on the list recommended > adding the rescue nil and it worked like a charm. > > Brent > > --- Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote: > >> I am using the very helpful file_column extension in >> my app. >> >> The uploading portion works great - no problems. >> >> Where I am having an issue is displaying the images >> in my view. My code >> looks like this: >> >> <% for @record in @main_box_releases -%> >> >> <%= image_tag(url_for_file_column("record", >> "record_cover")) %> >> >> <% end -% >> >> @record is an instance of a class called Release. It >> is not nil, removing >> the url_for_file_column makes all errors go away and >> other calls to @record >> complete just fine. >> >> I get this error: >> >> cannot convert nil into String >> >> I''ve tried many variations, such as: >> url_for_file_column(:record, "record_cover") >> url_for_file_column("release", "record_cover") >> url_for_file_column(@record, "record_cover") >> >> Nada on any of them. What am I doing wrong? >> >> Thanks, >> Hunter >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > > > __________________________________ > Yahoo! Music Unlimited > Access over 1 million songs. Try it free. > http://music.yahoo.com/unlimited/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
I take it back - the error goes away but nothing is getting output by the helper. The images are located in the correct place - that''s working just fine. So, this isn''t working for me. Any help is very much appreciated. Hunter> From: Brent Beardsley <brentbeardsley-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> > Reply-To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Date: Mon, 10 Oct 2005 11:22:07 -0700 (PDT) > To: <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Subject: Re: [Rails] Problem With url_for_file_column/file_column > > Hi Hunter, > > Try: > > <%= image_tag url_for_file_column("record", > "record_cover") rescue nil %> > > Note the rescue nil on the end - I was having the same > problem you were and several on the list recommended > adding the rescue nil and it worked like a charm. > > Brent > > --- Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote: > >> I am using the very helpful file_column extension in >> my app. >> >> The uploading portion works great - no problems. >> >> Where I am having an issue is displaying the images >> in my view. My code >> looks like this: >> >> <% for @record in @main_box_releases -%> >> >> <%= image_tag(url_for_file_column("record", >> "record_cover")) %> >> >> <% end -% >> >> @record is an instance of a class called Release. It >> is not nil, removing >> the url_for_file_column makes all errors go away and >> other calls to @record >> complete just fine. >> >> I get this error: >> >> cannot convert nil into String >> >> I''ve tried many variations, such as: >> url_for_file_column(:record, "record_cover") >> url_for_file_column("release", "record_cover") >> url_for_file_column(@record, "record_cover") >> >> Nada on any of them. What am I doing wrong? >> >> Thanks, >> Hunter >> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > > > __________________________________ > Yahoo! Music Unlimited > Access over 1 million songs. Try it free. > http://music.yahoo.com/unlimited/ > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Hi Hunter, On 10/10/05, Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote:> Where I am having an issue is displaying the images in my view. My code > looks like this: > > <% for @record in @main_box_releases -%> > > <%= image_tag(url_for_file_column("record", "record_cover")) %> > > <% end -%hmm, maybe some @records do not have an image uploaded? url_for_file_column currently raises an exception in that case (fix will be in the next version that is coming soon). Can you replace the line inside the for statement with a "<%@record.record_cover %>"? What is the output? Sebastian
Thanks for the reply. I did what you asked and there is no output from that line. So, it seems as if that ''record'' doesn''t have an image. Unfortunately, that''s not the case. Right now, there are two ''records'' in the database with ids 22 and 23. Under public, I have this: (@record is an instance of Release.rb) /release/record_cover/22/image.jpg /release/record_cover/23/image.jpg These were placed there using the upload helper from file_column. So, where am I going wrong? Thanks again - the extension seems like a great one, I just wish I could get it working for me.> From: Sebastian Kanthak <skanthak-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > Reply-To: <sebastian.kanthak-ZS8b95Whz3sUSW6y5lq3GQ@public.gmane.org> > Date: Mon, 10 Oct 2005 21:47:58 +0200 > To: Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> > Cc: Rails <rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > Subject: Re: Problem With url_for_file_column/file_column > > Hi Hunter, > > On 10/10/05, Hunter Hillegas <lists-HAWAbpnI61OZ1JSuHaJ1sQC/G2K4zDHf@public.gmane.org> wrote: >> Where I am having an issue is displaying the images in my view. My code >> looks like this: >> >> <% for @record in @main_box_releases -%> >> >> <%= image_tag(url_for_file_column("record", "record_cover")) %> >> >> <% end -% > > hmm, maybe some @records do not have an image uploaded? > url_for_file_column currently raises an exception in that case (fix > will be in the next version that is coming soon). > > Can you replace the line inside the for statement with a "<%> @record.record_cover %>"? What is the output? > > Sebastian