rails - converting an object to an array -


Hey, I'm trying to convert this object to an array array eg. Array (3,4,6)

  - - ruby ​​/ object: code attributes: candidate_id: "3" attributes_cache: {} - ruby ​​/ object: code attributes: candidate_id: "4" Attributes_cache: {} -! Ruby / object: Code attributes: candidate_id: "6" attributes_cache: {}  

Whatever I tried here

  results = @ intersection.map { | C | C.candidate_id}  

Thanks

Try the following: < <: p>

  • C [: candidate_id]

OR

  • c [: properties] [ : Candidate_ID]

I am not familiar with YAML, although you can try to create a hash instead of code objects. In addition, if you use the code class, you should make sure that you have more attr_accessor (and then your old code should work).


Comments