Forum: Ruby on Rails file_column with both root_path and store_dir

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ryan H. (Guest)
on 2006-01-17 10:17
(Received via mailing list)
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 topic is locked and can not be replied to.