我正在使用 Rails 3.2.5
。我有一个文件目前保存在我的公共(public)文件夹中
例如:/public/files/file.swf
此文件在其中加载几个相关的 swf 文件,这些文件也存在于/public/files 文件夹中。
这个“file.swf”正在我的 index.html 中访问,用于我对/member/mycontroller 的索引操作
<embed Xscale="scaleToFit" scale="noscale" width="100%" height="100%" name="fieldObj" id="fieldObj" authorative="userid,level,sport"
src="/files/file.swf"
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"/>
文件未加载,因为正在/views/member/mycontroller 文件夹中搜索该文件。
如果我指定它加载的 file.swf 的绝对路径,但在其中调用的相关 swf 文件无法加载,因为它们仍在/member/mycontroller 文件夹中查找。
是否有某种方法可以配置为跳过查找 member/mycontroller 并直接在 public/files 文件夹中查找?我在渲染不同 Controller 的一部分时遇到了类似的问题。
最佳答案
在公共(public)文件夹中创建一个“member/mycontroller”文件夹并将文件放入其中。
关于ruby-on-rails - 在 Controller View 中访问公共(public)文件。 Rails 将当前 Controller 的路径视为相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18399192/