微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – Ruby on Rails错误.处理控制器方法为png

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

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

这是我的控制器方法.

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

事情是我在我的控制台内得到2个电话.因此是一个错误.
这是我的控制台看起来像..

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

解决方法

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

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐