【发布时间】:2014-01-13 16:42:30
【问题描述】:
我想在模型中做这样的事情,使用像 db 这样的公用文件夹来存放文件。
all_images = []
(1..100).each do |image_number|
if File.exists?("/img/#{image_number}.jpg")
# add image path to the list
end
end
Rails 有没有办法以这种方式“查看”公共目录中的文件?
【问题讨论】:
-
是的。如果您使用的是 Rails 4,那么您想查看guides.rubyonrails.org/asset_pipeline.html。
-
在SO上多次给出你的问题的答案,下次使用搜索
-
Rails.root 你可能会感兴趣:stackoverflow.com/a/3724527/32453
标签: ruby-on-rails ruby