2011-04-12 54 views
0

當一些圖像沒有被發現(它的「src」屬性指向錯誤的道路),我得到以下錯誤:爲什麼ActionController處理圖像請求,但不處理流請求?

Processing ApplicationController#index (for 127.0.0.1 at 2011-04-12 16:44:19) [GET]

ActionController::RoutingError (No route matches "non-existent-image.jpg" with {:method=>:get}): /Library/Ruby/Gems/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in debug_load' /Library/Ruby/Gems/1.8/gems/ruby-debug-ide-0.4.9/lib/ruby-debug-ide.rb:109:in debug_program' /Library/Ruby/Gems/1.8/gems/ruby-debug-ide-0.4.9/bin/rdebug-ide:87 /usr/bin/rdebug-ide:19:in load' /usr/bin/rdebug-ide:19 -e:2:in load' -e:2

Rendering rescues/layout (not_found)

但是,當有一個HTML5視頻元素,我看不出有任何抱怨的ActionController,當它沒有找到。

這是怎麼回事?

回答

0

看起來您正在生成的HTML看起來像<img src="/non-existent-image.jpg">,並且該路徑未在您的config/routes.rb中定義,因此無法由Rails應用程序處理。

什麼你可能會打算是:

<%= image_tag('non-existent-image.jpg') %> 

這將生成一個標記,如下所示:

<img src="/images/non-existent-image.jpg"> 

只要該文件存在於你的public/文件夾,它應該工作。