我有一个文件列表,我尝试获取一个相对路径
file = "/Users/yves/github/local/workshop/public/uploads/craftwork/image/1/a1d0.jpg"
Rails.public_path => "/Users/yves/github/local/workshop/public"
# 我正在尝试获取 => "uploads/craftwork/image/1/a1d0.jpg"
file.relative_path_from(Rails.public_path) # is wrong
# raising : undefined method `relative_path_from' for #<String ( file is a String..)
# so I tried to use Pathname class
Pathname.new(file).relative_path_from(Rails.public_path)
# but the I get another error
# undefined method `cleanpath' for String
在 Rails 3.2 中是否不推荐使用 relative_path_from ?如果是的话,现在有什么好的?