Url_for_file_column not returning correct path

I added this test towards the end of the included
file_column_helper_test.rb that shipped with the file_column plugin:

def test_url_for_file_column_different_root_path
Entry.file_column :image, :root_path => File.join(RAILS_ROOT,
“public/files”)
e = Entry.new(:image => upload(f(“skanthak.png”)))
assert_match %r{/public/files/entry/image},
e.image_options[:store_dir]
assert e.save
assert_match %r{files/entry/image}, url_for_file_column(e, “image”)
end

the last assert_match did not pass…

  1. Failure:
    test_url_for_file_column_different_root_path(UrlForFileColumnTest)
    [file_column_helper_test.rb:59]:
    <"/entry/image/1/skanthak.png"> expected to be =~
    </files/entry/image/>.

The file is correctly stored in the :root_path specified. It’s as if
url_for_file_column doesn’t take it into account. Has anyone else
experienced this problem?

the url wouldn’t be using the rails_root because it’s looking for a web
accessible path (URL), not the filesystem path.

maybe you need to use :store_dir instead?

Nithin R. wrote:

I added this test towards the end of the included
file_column_helper_test.rb that shipped with the file_column plugin:

def test_url_for_file_column_different_root_path
Entry.file_column :image, :root_path => File.join(RAILS_ROOT,
“public/files”)
e = Entry.new(:image => upload(f(“skanthak.png”)))
assert_match %r{/public/files/entry/image},
e.image_options[:store_dir]
assert e.save
assert_match %r{files/entry/image}, url_for_file_column(e, “image”)
end

the last assert_match did not pass…

  1. Failure:
    test_url_for_file_column_different_root_path(UrlForFileColumnTest)
    [file_column_helper_test.rb:59]:
    <"/entry/image/1/skanthak.png"> expected to be =~
    </files/entry/image/>.

The file is correctly stored in the :root_path specified. It’s as if
url_for_file_column doesn’t take it into account. Has anyone else
experienced this problem?

On 3/3/06, dorian mcfarland [email protected] wrote:

the url wouldn’t be using the rails_root because it’s looking for a web
accessible path (URL), not the filesystem path.

maybe you need to use :store_dir instead?

I’m not sure how to use this option. I want the images stored in…

public/files/<model_name>/<attribute_name>/, instead of
public/<model_name>/<attribute_name>/

I’ve tried the following with no success (it just used the default
directory):

file_column( :file_name,
:options => {:mime_extensions => MIME_EXTENSIONS,
:store_dir => “files”},
:magick => {:versions => {:small => {:crop => “1:1”,
:size => “75x75”},
:medium => {:crop => “1:1”,
:size => “150x150”} } } )

I’m not sure what to set :store_dir as (I’ve tried a few different
combinations).