gpt4 book ai didi

ruby-on-rails - rails 和 Ahoy : No route matches [GET] "/ahoy/visits"

转载 作者:行者123 更新时间:2023-12-04 18:01:40 25 4
gpt4 key购买 nike

我正在使用 Ahoy gem 获取访问信息。但我注意到在生产中,我经常遇到以下错误:

No route matches [GET] "/ahoy/visits"

但是回溯没有显示任何我认识的文件。这是完整的跟踪:

ActionController::RoutingError: No route matches [GET] "/ahoy/visits"
... 27 non-project frames
1
File "/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/debug_exceptions.rb" line 21 in call
2
File "/app/vendor/bundle/ruby/2.0.0/gems/rollbar-2.6.3/lib/rollbar/middleware/rails/show_exceptions.rb" line 22 in call_with_rollbar
3
File "/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/show_exceptions.rb" line 30 in call
4
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/rack/logger.rb" line 38 in call_app
5
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/rack/logger.rb" line 20 in block in call
6
File "/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb" line 68 in block in tagged
7
File "/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb" line 26 in tagged
8
File "/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/tagged_logging.rb" line 68 in tagged
9
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/rack/logger.rb" line 20 in call
10
File "/app/vendor/bundle/ruby/2.0.0/gems/ahoy_matey-1.2.1/lib/ahoy/engine.rb" line 15 in block in call_with_quiet_ahoy
11
File "/app/vendor/bundle/ruby/2.0.0/gems/ahoy_matey-1.2.1/lib/ahoy/logger_silencer.rb" line 44 in silence_logger
12
File "/app/vendor/bundle/ruby/2.0.0/gems/ahoy_matey-1.2.1/lib/ahoy/engine.rb" line 14 in call_with_quiet_ahoy
13
File "/app/vendor/bundle/ruby/2.0.0/gems/request_store-1.2.1/lib/request_store/middleware.rb" line 8 in call
14
File "/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/request_id.rb" line 21 in call
15
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/methodoverride.rb" line 22 in call
16
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/runtime.rb" line 18 in call
17
File "/app/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/cache/strategy/local_cache_middleware.rb" line 28 in call
18
File "/app/vendor/bundle/ruby/2.0.0/gems/actionpack-4.2.2/lib/action_dispatch/middleware/static.rb" line 113 in call
19
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/sendfile.rb" line 113 in call
20
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/engine.rb" line 518 in call
21
File "/app/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb" line 164 in call
22
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/lock.rb" line 17 in call
23
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/content_length.rb" line 15 in call
24
File "/app/vendor/bundle/ruby/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb" line 88 in service
25
File "/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb" line 138 in service
26
File "/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb" line 94 in run
27
File "/app/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb" line 295 in block in start_thread

这只是一个爬行所有 URL 的机器人吗?如何根据痕迹查明它的来源?

最佳答案

这个问题的原因似乎是机器人爬进了它们不应该去的地方。我们通过在 robots.txt 文件中添加一行来解决这个问题:

User-agent: *
Disallow: /ahoy/

这应该可以防止机器人尝试任何以/ahoy/开头的路由,例如我们的/ahoy/visits 路由。并非所有机器人都尊重 robots.txt 文件,但它们中有足够多的机器人这样做,我们现在很少看到这种错误发生。

关于ruby-on-rails - rails 和 Ahoy : No route matches [GET] "/ahoy/visits",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34325374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com