0
params에서 해시 값을 추출하는 더 좋은 방법을 알고 싶습니다. params 객체를 파라미터는 (기억 내 PARAMS 이름이있는 params이다 : ad_template]) : 다음과 같은params에서 해시 값 가져 오기
{"name"=>"name",
"description"=>"description",
"tag_list"=>"Software Development",
"objective"=>"VIDEO_VIEW",
"ad_creative_templates_attributes"=>{
"0"=>{"creative_template_id"=>"2430", "_destroy"=>"false"}
},
"ad_target_templates_attributes"=>{
"0"=>{"target_template_id"=>"1526", "_destroy"=>"false"}
}
}
지금 내가이 PARAMS에서 "creative_template_id"의 값을 좀하고 싶습니다.
나는 코드 아래 실행하여이 값을 얻을 수있는 오전 : 나에게 올바른 값 2430을 제공하지만 난이 방법을 좋아하지 않는다params[:ad_template][:ad_creative_templates_attributes].first.second[:creative_template_id]
합니다. 그래서 params에서 그 값을 추출하는 더 나은 솔루션을 알고 싶습니다.
감사합니다.
, 뭔가 : http://stackoverflow.com/questions/15031412/search-for-key-in-a- 중첩 된 해시 - 인 - 레일 –