如何通过 Mongrel Web 服务器指定 Rails 中的文件路径
我有一个从 Rails 加载 swf 文件 flaMovie.swf 的请求。 swf 文件位于目录 /home/user1/railsproj/flash。
我在视图目录下有代码index.rhtml来显示.swf文件,
ID=flaMovie WIDTH=250 HEIGHT=250>
当我运行代码时,出现错误
ActionController::RoutingError (没有路由与 {:method=>:get} 匹配“/home/user1/railsproj/flash/flaMovie.swf”): /vendor/rails/actionpack/lib/action_controller/routing.rb:1441:in recognize_path' /vendor/rails/actionpack/lib/action_controller/routing.rb:1424:in
识别' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:170:in handle_request' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in
dispatch' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in dispatch_cgi' /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in
调度' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:在进程中' /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in
synchronize'
我的rails项目位于/home/ user1/railsproj 和 Web 服务器是 Mongrel Web 服务器。
如何指定rhtml文件中的路径以便Mongrel服务器能够找到该文件?多谢,
I have a request to load a swf file, flaMovie.swf from rails. The swf file is located the directory /home/user1/railsproj/flash.
I have the code index.rhtml under view directory to show the .swf file,
ID=flaMovie WIDTH=250 HEIGHT=250>
When I ran the code, I got the error,
ActionController::RoutingError (No route matches "/home/user1/railsproj/flash/flaMovie.swf" with {:method=>:get}):
/vendor/rails/actionpack/lib/action_controller/routing.rb:1441:in recognize_path'
recognize'
/vendor/rails/actionpack/lib/action_controller/routing.rb:1424:in
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:170:in handle_request'
dispatch'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:115:in
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:126:in dispatch_cgi'
dispatch'
/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:9:in
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:in process'
synchronize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in
My rails project is located in /home/user1/railsproj and the web server is Mongrel web server.
How to specify the path in the rhtml file so that Mongrel server is able to locate the file? Thanks a lot,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将文件放入项目目录内的
public
目录中,其路径仅为yourserver.com/flaMovie.swf
。Put your file in
public
directory inside your project directory and path to it is justyourserver.com/flaMovie.swf
.