2017-02-14 5 views
0

マスタースコープ内のslave1スコープで定義された変数にアクセスしたいと思います。どのように変数を適切にスコープしてスレーブブロックに設定し、マスターブロックで使用できるようにするのですか?Rails、Octopus、スレーブで定義されたマスターのアクセス変数?

Octopus.using(:slave1) do 
    locations_with_wrong_country_code_ids = Location.where(country: "USA").ids 
end 

Octopus.using(:master) do 
    Location.where(id: locations_with_wrong_country_code_ids).each do |location| 
    location.country = "US" 
    location.save 
    end 
end 

答えて

0

これを行います。

locations_with_wrong_country_code_ids = Octopus.using(:slave1) do 
    Location.where(country: "USA").ids 
end 

Octopus.using(:master) do 
    Location.where(id: locations_with_wrong_country_code_ids).each do |location| 
    location.country = "US" 
    location.save 
    end 
end 
関連する問題