Hi all,
I''m trying to use file_column to upload a picture but
I''m getting the following error:
"cannot convert nil into String"
caused by the last line in
FileColumnHelper::url_for_file_column(object_name,
method)
url << object.send("#{method}_relative_path")
I don''t have any images uploaded for existing entries
so does this not work when images are missing? Or
what am I missing?
Thanks,
Brent
__________________________________
Yahoo! Mail - PC Magazine Editors'' Choice 2005
http://mail.yahoo.com
Brent-
Yes you will get an error if you try to do the
url_for_file_column without a value or a path to a photo there
already. The easiest way around this is to rescue the nil value like
this:
<%= image_tag url_for_file_column rescue nil %>
HTH
Ezra
On Oct 3, 2005, at 7:47 PM, Brent Beardsley wrote:
> Hi all,
>
> I''m trying to use file_column to upload a picture but
> I''m getting the following error:
>
> "cannot convert nil into String"
>
> caused by the last line in
>
> FileColumnHelper::url_for_file_column(object_name,
> method)
>
> url << object.send("#{method}_relative_path")
>
> I don''t have any images uploaded for existing entries
> so does this not work when images are missing? Or
> what am I missing?
>
> Thanks,
>
> Brent
>
>
>
> __________________________________
> Yahoo! Mail - PC Magazine Editors'' Choice 2005
> http://mail.yahoo.com
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-Ezra Zygmuntowicz
WebMaster
Yakima Herald-Republic Newspaper
ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org
509-577-7732
Brent Beardsley wrote:> Hi all, > > I''m trying to use file_column to upload a picture but > I''m getting the following error: > > "cannot convert nil into String" > > caused by the last line in > > FileColumnHelper::url_for_file_column(object_name, > method) > > url << object.send("#{method}_relative_path") > > I don''t have any images uploaded for existing entries > so does this not work when images are missing? Or > what am I missing? > > Thanks, > > Brent > >Hi, You should check if the image is empty, i.e.: <% if @entry.image %> <%= image_tag( url_for_file_column(@entry, ''image'')) %> <% end %> Eszter -- Primalgrasp LLC http://primalgrasp.com
Cool, thanks for the two replies they helped and it''s working as I expected. The other problem I was having was that I was specifying multipart in the url params part of the start_form_tag instead of the options params part. Thanks again, Brent --- Biro Eszter <biro.eszter-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Brent Beardsley wrote: > > Hi all, > > > > I''m trying to use file_column to upload a picture > but > > I''m getting the following error: > > > > "cannot convert nil into String" > > > > caused by the last line in > > > > FileColumnHelper::url_for_file_column(object_name, > > method) > > > > url << > object.send("#{method}_relative_path") > > > > I don''t have any images uploaded for existing > entries > > so does this not work when images are missing? Or > > what am I missing? > > > > Thanks, > > > > Brent > > > > > Hi, > > > You should check if the image is empty, i.e.: > <% if @entry.image %> > <%= image_tag( url_for_file_column(@entry, > ''image'')) %> > <% end %> > > > Eszter > > -- > Primalgrasp LLC > http://primalgrasp.com > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >__________________________________ Yahoo! Mail - PC Magazine Editors'' Choice 2005 http://mail.yahoo.com