Rails&啊啊:没有路线匹配[GET]“/ ahoy / visits”

时间:2015-12-17 01:53:14

标签: ruby-on-rails ahoy

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

  

没有路线匹配[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

这只是一个机器人抓取所有网址吗?如何根据痕迹找出它的来源?

2 个答案:

答案 0 :(得分:0)

您需要在您的routes.rb文件中安装ahoy引擎:

mount Ahoy::Engine => "/ahoy", as: :my_ahoy

答案 1 :(得分:0)

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

User-agent: *
Disallow: /ahoy/

这应该可以防止漫游器尝试以/ ahoy /开头的任何路由,例如我们的/ ahoy / visits路由。