How to convert ActiveRecord results into an array of hashes

后端 未结 3 2083
醉梦人生
醉梦人生 2020-12-04 06:29

I have an ActiveRecord result of a find operation:

tasks_records = TaskStoreStatus.find(
  :all,
  :select => \"task_id, store_name, store_region\",
  :co         


        
3条回答
  •  猫巷女王i
    2020-12-04 07:29

    May be?

    result.map(&:attributes)
    

    If you need symbols keys:

    result.map { |r| r.attributes.symbolize_keys }
    

提交回复
热议问题