Ruby on Rails 错误.处理控制器方法为 png [英] Ruby on Rails Error. Processing Controller method as png

查看:41
本文介绍了Ruby on Rails 错误.处理控制器方法为 png的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have given this in my route.

get '/custom_page/:name' => 'custom_page#load_content'

这是我的控制器方法.

def load_content
    page_name = (params[:name]).split("_").join(" ")
    p "---------------------"
    p page_name
end

我在控制台中收到了 2 个 get 调用.因此是一个错误.这是我的控制台的样子..

Thing is im getting 2 get calls inside my console. and hence an error. here is what my console looks like..

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"

为什么会出现那个图标?如何防止这个被调用?由 CustomPageController#load_content 处理为 PNG

Why is that favicon coming? How to prevent this from getting called? Processing by CustomPageController#load_content as PNG

推荐答案

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

Many browsers look for favicon.png files on your server (that is the icon shown near the title of the page). It is a known symptom seeing 404s for favicon.png in server logs.

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

The easiest way to avoid a browser looking at internal links for a favicon is to put a favicon.ico at the website root, or to add a <link rel to your layout template:

<link rel="shortcut icon" href="http://example.com/myicon.ico" />

这篇关于Ruby on Rails 错误.处理控制器方法为 png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆