Ruby on Rails 错误。处理控制器方法为 png

Nid*_*S G 5 ruby ruby-on-rails ruby-on-rails-4

我已经在我的路线中给出了这个。

get '/custom_page/:name' => 'custom_page#load_content'
Run Code Online (Sandbox Code Playgroud)

这是我的控制器方法。

def load_content
    page_name = (params[:name]).split("_").join(" ")
    p "---------------------"
    p page_name
end
Run Code Online (Sandbox Code Playgroud)

问题是我在控制台内接到了 2 个 get 电话。因此出现错误。这是我的控制台的样子..

Started GET "/en/custom_page/Nidhin_Test_Page" for 127.0.0.1 at 2014-05-12 11:50:34 +0530
  ActiveRecord::SchemaMigration Load (0.2ms)  SELECT `schema_migrations`.* FROM `schema_migrations`
Processing by CustomPageController#load_content as HTML
  Parameters: {"locale"=>"en", "name"=>"Nidhin_Test_Page"}
  "---------------------"    
  "Nidhin Test Page"
  Rendered custom_page/load_content.html.erb within layouts/calculator (2.4ms)
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 2 ORDER BY `users`.`id` ASC LIMIT 1
  Rendered layouts/_calculator_script_top.html.erb (45.4ms)
  Rendered layouts/_calculator_header.html.erb (217.5ms)
  MenuItem Load (0.2ms)  SELECT `menu_items`.* FROM `menu_items` ORDER BY `menu_items`.`menu_priority` ASC
  Rendered layouts/_calculator_menu.html.erb (15.4ms)
  Rendered layouts/_calculator_script_bottom.html.erb (0.6ms)
Completed 200 OK in 325ms (Views: 295.8ms | ActiveRecord: 3.9ms)


Started GET "/en/custom_page/favicon.png" for 127.0.0.1 at 2014-05-12 11:50:35 +0530
Processing by CustomPageController#load_content as PNG
  Parameters: {"locale"=>"en", "name"=>"favicon"}
"---------------------"
"favicon"
Completed 500 Internal Server Error in 6ms
  Rendered /home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/exception_notification-4.0.1/lib/exception_notifier/views/exception_notifier/_request.text.erb (3.3ms)
  Rendered /home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/exception_notification-4.0.1/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.6ms)
  Rendered /home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/exception_notification-4.0.1/lib/exception_notifier/views/exception_notifier/_session.text.erb (0.8ms)
  Rendered /home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/exception_notification-4.0.1/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.2ms)
  Rendered /home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/exception_notification-4.0.1/lib/exception_notifier/views/exception_notifier/_environment.text.erb (3.2ms)
  Rendered /home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/exception_notification-4.0.1/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.2ms)
  Rendered /home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/exception_notification-4.0.1/lib/exception_notifier/views/exception_notifier/_backtrace.text.erb (0.6ms)
  Rendered /home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/exception_notification-4.0.1/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb (34.7ms)

An ActionView::MissingTemplate occurred in custom_page#load_content:

  Missing template custom_page/load_content with {:locale=>[:en], :formats=>[:png], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :arb]}. Searched in:
  * "/home/nithin/mobomo/Projects/sfth/app/views"
  * "/home/nithin/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-c4a123d48850/app/views"
  * "/home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/kaminari-0.15.0/app/views"
  * "/home/nithin/.rvm/gems/ruby-2.0.0-p353/gems/devise-3.2.2/app/views"
Run Code Online (Sandbox Code Playgroud)

为什么那个图标会出现?如何防止这个被调用?Processing by CustomPageController#load_content as PNG

Uri*_*ssi 3

许多浏览器会在您的服务器上查找favicon.png文件(即页面标题附近显示的图标)。在服务器日志中看到404favicon.png是一个已知症状。

避免浏览器查看 a 的内部链接的最简单方法favicon是将 a 放在favicon.ico网站根目录中,或者将 a 添加<link rel到布局模板中:

<link rel="shortcut icon" href="http://example.com/myicon.ico" />
Run Code Online (Sandbox Code Playgroud)