0
我需要使用redis-objects寶石將散列存儲到Redis中。自述文件中包含hash_key
。但是沒有這方面的例子。如何在Redis Objects gem中使用hash_key?
我得到一個錯誤:
NoMethodError: undefined method `fantasy_points_details=' for #<InningPlayer:0x007f820adb68a0>
當我這樣做:
inning_player_instance.fantasy_points_details = {a: 1}
像這樣的模式:
class InningPlayer < ActiveRecord::Base
include Redis::Objects
hash_key :fantasy_points_details
end
但吸氣工作:
> inning_player_instance.fantasy_points_details
=> #<Redis::HashKey:0x007f820adf4470>
此外,你必須做'inning_player_instance.fantasy_points_details [ 「一」] = 1'設置和獲取哈希一次一個價值。 – nikkon226