如何在 Rails 中记录搜索?
我想保留用户在我的网站上使用 sunspot-rails gem 进行的所有搜索的日志。我不需要应用程序实时访问日志,因为它们用于稍后处理的分析。
我认为我应该在 Rails 中而不是在 solr 本身中进行日志记录,以便我可以访问整个会话,但我不确定如何构建它。有标准方法吗?我看到这个 问题 但我认为会有一些东西比我自己在 ApplicationController 中编写更通用。
I'd like to keep a log of all searches that users do on my site which uses the sunspot-rails gem. I don't need the logs to be real-time accessible by my application as they're for analytics that will be processed later.
I'm thinking that I should do the logging in rails rather than in solr itself so that I have access to the entire session, but I'm not sure how to build that. Is there a standard method for this? I saw this question but I would think there would be something more generic than writing it all myself in ApplicationController.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最终答案取决于您在何处实施搜索。如果您有一个搜索控制器,请在那里进行日志记录。如果您有一组搜索控制器,请在每个控制器中执行此操作,或者创建一个基类,在基类中执行过滤/日志记录。
你能提供更多细节吗?
The ultimate answer depends on howwhere you're implementing your search. If you have a single search controller, do the logging there. If you have a collection of search controllers, either do it in each one, or create a base class, do the filter/logging in the base class.
Can you provide any more details?