0
to_xml 모델 메소드에 대한 오버라이드를 작성했으며 지금은 심볼 => 값 쌍인 경우 해시 속성을 세트로 변환하려고 시도하지만 실제로 성공하지 못했습니다. .레일 3 : to_xml 모델 메소드의 오버라이드 (override)에서 해시 속성
intersected_categories
방법의 결과는 해시 같은 :
{:"1"=>["Broken Board", false], :"2"=>["Sticking", false], :"3"=>["Bottom tier missing", false], :"4"=>["Bad I/L", false], :"5"=>["Delamination", false], :"7"=>["Sheet level - smile", false], :"8"=>["Sheet level - frown", false], :"9"=>["Missing SS", false]}
def to_xml (options={})
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
xml.instruct! unless options[:skip_instruct]
xml.wip @wip,
:number => self.number,
:start_time => self.wip_start_time,
:end_time => self.wip_end_time,
:line => self.system.name,
:shift => self.shift,
:crew => self.crewF,
:sm_crew => self.crewSM,
:sm_shift => self.shiftSM,
:product => self.SMMainGroup,
:product_group => self.product_group,
:sheets => self.sheets,
:interleavers => self.interleavers,
:wip_grade => self.intersected_categories,
:comment => self.comment
end
필자가 성공하지 몇 가지를 시도한 to_xml 방법 :
def to_xml (options={})
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:indent])
xml.instruct! unless options[:skip_instruct]
@wip.intersected_categories.each do |grade|
wip_categories << {grade[1][0].to_sym => grade[0][1]}
end
.
.
:comment => self.comment,
wip_categories #explodes
end
###### another try
:interleavers => self.interleavers,
:wip_grade => self.intersected_categories,
:comment => self.comment,
self.intersected_categories.each do |grade|
<< grade[1][0].to_sym => grade[0][1] #with/without {} it keeps failing
end
end
하나를 어떻게 내가 필요한 것을 얻을 수 있을까?
업데이트
현재 XML :
<wip number="123h11008" start_time="2014-05-13 09:21:00 -0500" end_time="" line="cl1" shift="1" crew="A" sm_crew="A" sm_shift="1" product="1111111" product_group="G2" sheets="0" interleavers="0" wip_grade="{:"2"=>["Bottom Tier Missing", false], :"3"=>["Falling", false], :"4"=>["Broken Boards", false], :"5"=>["Crown", false], :"6"=>["DIP", false], :"7"=>["Green Boards", false], :"8"=>["Delamination", false], :"9"=>["Bad I/L", false]}" comment=""/>
예상 XML :
<wip number="123h11008" start_time="2014-05-13 09:21:00 -0500" end_time="" line="cl1" shift="1" crew="A" sm_crew="A" sm_shift="1" product="1111111" product_group="G2" sheets="0" interleavers="0" Bottom Tier Missing=false Falling = false Broken Boards = false Crown = false DIP = false Green Boards = false Delamination = false Bad I/L = false comment=""/>
당신이 결과를 예상 무엇 게재 할 수 있습니까? – BroiSatse
@BroiSatse 업데이트 –