Skip to content

Instantly share code, notes, and snippets.

@goodviber
Created March 9, 2017 11:12
Show Gist options
  • Save goodviber/601349c93e2e238fc19c5c591c4da3dd to your computer and use it in GitHub Desktop.
Save goodviber/601349c93e2e238fc19c5c591c4da3dd to your computer and use it in GitHub Desktop.
Array to ActiveRecord relation
def job_history
#catch double employee association update
@histories = @job.versions.delete_if { |version| version.changeset.keys[0] == "updated_at" }
#change array to ActiveRecord relation
@histories = @job.versions.where(id: @histories.map(&:id)).paginate(:page => params[:page], :per_page => 15)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment