I have an active record result as a result of a search operation
tasks_records = TaskStoreStatus.find(:all,:select => "task_id, store_name, store_region", :conditions => ["task_status = ? and store_id= ?","f" ,store_id])
Now I want to convert these results to an array of hashes, as shown below
[0] -> { :task_d => 10, :store_name=> "Koramanagala", :store_region=> "India" } [1] -> { :task_d => 10, :store_name=> "Koramanagala", :store_region=> "India" } [2] -> { :task_d => 10, :store_name=> "Koramanagala", :store_region=> "India" }
So, I can iterate through the array and add additional elements to the hashes, and then convert the result to JSON for my API response!
arrays activerecord hash
Avinash Mb Mar 15 '13 at 8:40 2013-03-15 08:40
source share