Forum: Ruby on Rails getting nil errors on file_column after update

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ramin B. (Guest)
on 2005-11-22 22:56
(Received via mailing list)
I have file_column setup as a svn:external, so I'm basically always
running
the latest version. There was a recent update to file_column and after
the
update, my application breaks. here is the error message, any ideas?

can't convert nil into String

./script/../config/../vendor/plugins/file_column/lib/file_column.rb:144:in
`join'
./script/../config/../vendor/plugins/file_column/lib/file_column.rb:144:in
`absolute_path'
./script/../config/../vendor/plugins/file_column/lib/file_column.rb:558:in
`image'
#{RAILS_ROOT}/app/views/user/_edit.rhtml:1:in `_run_rhtml_user__edit'
#{RAILS_ROOT}/app/views/user/edit.rhtml:8:in `_run_rhtml_user_edit'


This is happening when I try to upload a file. I haven't changed
anything in
my model, view or controller. Here are the relevant code snippets:

Model (Profile):

file_column :image, :magick => { :geometry => '500>', :versions => {
'small' => '50>', 'medium' => '200>' } }


Controller (User)

# I do have an instance of my profile object in my view
@profile = @user.profiles.find_first


View (edit)

<% if not @profile.image.nil? %> <-- this is the line throwing the
exception
<tr>
  <th></th>
  <td><%= image_tag url_for_file_column('profile', 'image', 'small')
%></td>
</tr>
<% end %>

<%= file_column_field 'profile', 'image' %>


Profile Table

CREATE TABLE profiles (
  ....
  image VARCHAR(50) default NULL,
  ...
);
Ramin B. (Guest)
on 2005-11-25 21:41
(Received via mailing list)
Just bumping this up cause I never got a reply and still getting
error. Any help would be greatly appreciated.



On 11/22/05, Ramin <removed_email_address@domain.invalid> wrote:
>
> 'small' => '50>', 'medium' => '200>' } }
>  <% if not @profile.image.nil? %> <-- this is the line throwing the
>
>
>  Profile Table
>  CREATE TABLE profiles (
>  ....
>  image VARCHAR(50) default NULL,
>  ...
> );
>
>


--
- Ramin
http://www.getintothis.com/blog
ol1barn3s (Guest)
on 2005-11-25 23:14
(Received via mailing list)
my 2 cents would be to try using

<%= image_tag url_for_file_column('profile', 'image', 'small') if
@profile.image %>

2005/11/25, Ramin <removed_email_address@domain.invalid>:
Ramin B. (Guest)
on 2005-11-26 00:19
(Received via mailing list)
Well, I would use that logic, but i have more HTML tags that I don't
want to show if the image is NIL. I think the logic is pretty much the
same and isn't the source of the real problem. I looked at the
file_column code and it seems like its trying to "join" some strings
with a nil object (line 144 in file_column.rb - the variable subdir is
defaulted to nil)

When I change the code and set the default value of subdir to an empty
string as opposed to nil, I no longer get that error. However, since
the code was changed to use subdirectories instead of
imagefile_version.ext, my images are not being copied or moved over to
the proper subdirectories ("medium" and "small", in my case.)

Another weird thing is that subdirectories are actually being created,
but their names are totally random strings and numbers. Its as if the
code was creating the directories not based off of the versions I
specify, but based on the hash value of the object id or something.
Not too familiar with Ruby and object names/ids, but thats just my
guess.

On 11/25/05, Oliver B. <removed_email_address@domain.invalid> wrote:
> >
> > > `image'
> > >  file_column :image, :magick => { :geometry => '500>', :versions => {
> > >  View (edit)
> > >
> >
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
- Ramin
http://www.getintothis.com/blog
This topic is locked and can not be replied to.