Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/openstax/utilities/active_record_extensions.rb
Class Method Summary collapse
Methods included from OpenStax::Utilities::DelegateAccessControl
delegate_access_control, delegate_access_control_to
Methods included from OpenStax::Utilities::ActsAsNumberable
Class Method Details
.find_in_specified_order(ids) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/openstax/utilities/active_record_extensions.rb', line 4 def self.find_in_specified_order(ids) items = find(ids) order_hash = {} ids.each_with_index {|id, index| order_hash[id.to_i]=index} items.sort_by!{|item| order_hash[item.id]} end |