File_column with both root_path and store_dir

I store my file_column database outside of my RAILS_ROOT.

It seems to work in real life, but not in tests.

In the tests, I can’t set both the root_path and the store_dir. In
tests, setting the store_dir option will override the root_path
option. The only way for root_path to work is to remove store_dir. I
think the problem is in file_column.rb on line 22:
options[:store_dir] ||= File.join(options[:root_path], model, attr)

Here’s my test:

def test_absolute_path_outside_rails_root
# We might want to store our files on another file system
# We also want to give the user their own directory
Entry.file_column :image, {:root_path => “/u/
file_column_db”, :store_dir => store_dir_method}
e =
e.image = uploaded_file(file_path(“kerb.jpg”), “image/jpeg”,
assert File.exists?(e.image)
assert e.image !~ /../, “#{e.image} is not a simple path”
assert_match %r{/u/file_column_db/somebodys_account/images},
def store_dir_method
File.join(“somebodys_account”, “images”)

This fails with:

  1. Failure:
    test_absolute_path_outside_rails_root(ResourceTest) [test/unit/
    1137483590.895686.58774/kerb.jpg"> expected to be =~

Any ideas would be appreciated!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs