ActiveRecord::RecordNotFound - 找不到 id=favicon.ico 的位置

问题描述 投票:0回答:2

我在本地运行 Sinatra 应用程序,它工作正常,但我无法将该应用程序部署到 heroku 或 EC2。我在我的日志(本地)中收到以下有关 favicon.ico 的信息。我已将此文件添加到我的应用程序中,但它仍然给我这个:

ActiveRecord::RecordNotFound - 无法找到 id=favicon.ico 的位置

关于如何解决这个问题有什么想法吗?

== Sinatra/1.4.2 has taken the stage on 4567 for development with backup from Thin
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on localhost:4567, CTRL+C to stop
D, [2013-06-06T20:18:30.470678 #1786] DEBUG -- :   Location Load (0.2ms)  SELECT "locations".*        FROM "locations" 
127.0.0.1 - - [06/Jun/2013 20:18:30] "GET / HTTP/1.1" 200 2552 0.0419
D, [2013-06-06T20:18:30.763844 #1786] DEBUG -- :   Location Load (0.2ms)  SELECT "locations".*   FROM "locations" WHERE "locations"."id" = ? LIMIT 1  [["id", "favicon.ico"]]
ActiveRecord::RecordNotFound - Couldn't find Location with id=favicon.ico:
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/activerecord- 3.2.13/lib/active_record/relation/finder_methods.rb:343:in `find_one'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:314:in `find_with_ids'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:107:in `find'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/activerecord-3.2.13/lib/active_record/querying.rb:5:in `find'
app.rb:36:in `block in <main>'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1415:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1415:in `block in compile!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:944:in `[]'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:944:in `block (3 levels) in route!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:960:in `route_eval'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:944:in `block (2 levels) in route!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:981:in `block in process_route'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:979:in `catch'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:979:in `process_route'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:943:in `block in route!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:942:in `each'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:942:in `route!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1053:in `block in dispatch!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `block in invoke'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `catch'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `invoke'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1050:in `dispatch!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:878:in `block in call!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `block in invoke'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `catch'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1035:in `invoke'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:878:in `call!'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:864:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/xss_header.rb:18:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/path_traversal.rb:16:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/json_csrf.rb:18:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/base.rb:49:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-protection-1.5.0/lib/rack/protection/frame_options.rb:31:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.5.2/lib/rack/logger.rb:15:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.5.2/lib/rack/commonlogger.rb:33:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:209:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:202:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/showexceptions.rb:21:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:172:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1947:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1610:in `block in call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1693:in `synchronize'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/sinatra-1.4.2/lib/sinatra/base.rb:1610:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/thin-1.5.1/lib/thin/connection.rb:81:in `block in pre_process'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/thin-1.5.1/lib/thin/connection.rb:79:in `catch'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/thin-1.5.1/lib/thin/connection.rb:79:in `pre_process'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `call'
/Users/Home/.rvm/gems/ruby-1.9.3-p374/gems/eventmachine-1.0.3/lib/eventmachine.rb:1037:in `block in spawn_threadpool'
ruby sinatra
2个回答
0
投票

您是否有一个

/:something
路线,然后尝试根据
:something
从数据库加载记录。浏览器似乎要求输入
/favicon.ico
,而您的应用程序正在尝试在数据库中查询 id 为
favicon.ico
的记录。

您有

/:something
路线吗?如果有的话,它有什么作用?


0
投票

当您在 Sinatra 中加载页面时,浏览器想要检索 favicon.ico 当它找不到文件时,Sinatra 会尝试获取该文件,类似于

get '/favicon.ico' do
  "Hello World"
end

但是该路由不存在,目前还不清楚为什么 Active-Record 会给出错误,但如果您将有效的 favicon.ico 文件放在公共文件夹下,问题应该可以解决。

© www.soinside.com 2019 - 2024. All rights reserved.