Converting an array into active record in rails

Converting an array into active record in rails

So this is a common requirement which every one of us have to face once a while.
In my project I was getting the array of result from a modal method i.e backup_projects. Now to apply sorting and pagination I have to convert it into rails active record.

As I could have applied sorting on active records only. So I came across a way as shown below.

     project = Project.backup_projects
      project.map{|i| i.id}
      @projects = Project.where(:id => project)
@projects was an active record thus and served my purpose.
Advertisements