如何:在 Rails 应用程序中查看 Redis 数据(使用 Soulmate)
HOW TO: View Redis Data inside Rails application (using Soulmate)
我是 rails 上 ruby 的新手。
目前我正在使用 Redis/Soulmate 的自动完成功能。我正在启动一个新的加载器并像这样放入我的约会模型:
loader = Soulmate::Loader.new("appointments")
puts loader.inspect
我得到输出:
#<Soulmate::Loader:0x007fdca25bd840 @type="appointments">
但是如果我开始像这样添加到加载器:
loader.add("term"=>"randomappointment", "id"=>1)
我如何在我的 rails 应用程序中查看此命令的输出 - 我想查看我刚刚在加载程序中输入的数据(灵魂伴侣哈希)。我正在尝试这样的操作,但没有任何效果:
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 class 这样做的,就像这样:
term = "randomappointment"
result = Soulmate::Matcher.new("appointments").matches_for_term(term)
我是 rails 上 ruby 的新手。
目前我正在使用 Redis/Soulmate 的自动完成功能。我正在启动一个新的加载器并像这样放入我的约会模型:
loader = Soulmate::Loader.new("appointments")
puts loader.inspect
我得到输出:
#<Soulmate::Loader:0x007fdca25bd840 @type="appointments">
但是如果我开始像这样添加到加载器:
loader.add("term"=>"randomappointment", "id"=>1)
我如何在我的 rails 应用程序中查看此命令的输出 - 我想查看我刚刚在加载程序中输入的数据(灵魂伴侣哈希)。我正在尝试这样的操作,但没有任何效果:
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 class 这样做的,就像这样:
term = "randomappointment"
result = Soulmate::Matcher.new("appointments").matches_for_term(term)