ruby-on-rails - 如何 : View Redis Data inside Rails application (using Soulmate)

标签 ruby-on-rails autocomplete redis

我是 ruby​​ on rails 的新手。

目前我正在使用 Redis/Soulmate 来实现自动完成功能。我正在启动一个新的加载器并像这样放入我的约会模型:

loader = Soulmate::Loader.new("appointments")
puts loader.inspect

我得到输出:

#<Soulmate::Loader:0x007fdca25bd840 @type="appointments">

但是如果我开始像这样添加到加载器:

loader.add("term"=>"randomappointment", "id"=>1)

我如何在我的 Rails 应用程序中查看此命令的输出 - 我想查看我刚刚在加载程序中输入的数据(soulmate 哈希)。我正在尝试这样的事情,但没有任何效果:

puts soulmate-data:appointments 1 or 
puts soulmate-data["appointments"]

注意:我可以在我的终端中使用

$ redis-cli
hget soulmate-data:appointments 1

给出输出:

"{\"term\":\"randomappointment\",\"id\":1}"

有什么想法吗?我正在使用 Redis 2.8.19、Rails 4.1.6

最佳答案

我想通了,我是这样使用 Soulmate::Matcher 类做到这一点的:

term = "randomappointment" 
result = Soulmate::Matcher.new("appointments").matches_for_term(term)

关于ruby-on-rails - 如何 : View Redis Data inside Rails application (using Soulmate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29572654/

相关文章:

ruby-on-rails - 用于构建社交网站的 Ruby 电子书

c# - WPF 建议文本框

javascript - JqueryUI 自动完成 : autoFocus = true won't do anything

node.js - Redis 键空间事件未触发

twitter - Redis pubsub 和 twitter 就像新闻源一样?

ruby-on-rails - 访问 a 的属性在 Rails 中有很多关联

ruby-on-rails - 想要以我的嵌套嵌套属性 Rails 的 json 格式响应

ruby-on-rails - 无法运行新应用程序

linux - 如何在Linux中创建快捷方式?

python - Redis哈希函数和数据分区