2017-02-14 23 views
0

Я хотел бы получить доступ к переменной, определенной в области slave1 внутри основной области. Как правильно изменить видимость переменной, чтобы она была установлена ​​в подчиненном блоке и доступна в главном блоке?Rails, Octopus, переменная доступа в master, определенная в slave?

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