No release in over 3 years
Low commit activity in last 3 years
Convert Array to ActiveRecord::Relation without database access
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Build Status Gem Version

ArrayToActiveRecord

Convert Array to ActiveRecord::Relation without database access

Support Version

ActiveRecord v4.2 ~ v6.0.0.rc1

Currently, Testing matrix of Ruby/ActiveRecord versions on Travis CI.

ActiveRecord \ Ruby 2.3 2.4 2.5 2.6
4.2 - -
5.0 -
5.1 -
5.2 -
6.0.rc1 - -

Installation

Add this line to your application's Gemfile:

gem 'array_to_activerecord'

And then execute:

$ bundle

Or install it yourself as:

$ gem install array_to_activerecord

Usage

array = [ Customer.find(1), Customer.find(2), Customer.find(3) ]
# Customer Load (0.1ms)  SELECT  `customers`.* FROM `customers` WHERE `customers`.`id` = 1 LIMIT 1
# Customer Load (0.1ms)  SELECT  `customers`.* FROM `customers` WHERE `customers`.`id` = 2 LIMIT 1
# Customer Load (0.1ms)  SELECT  `customers`.* FROM `customers` WHERE `customers`.`id` = 3 LIMIT 1

# Convert without database access
records = ArrayToActiveRecord.convert(array, model_class: Customer)

Testing

bundle exec rake

Testing with multiple versions of ActiveRecord

First, you need to install the dependencies for each appraisal

bundle exec appraisal install

Next, run tests across all ActiveRecord versions

bundle exec appraisal rake

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/potato2003/array_to_activerecord.