Rails 4.1 ActiveRecord::relation is no more like Array

前端 未结 1 1595
一向
一向 2020-12-17 09:19

in Rails 4.0.4 this code work:

mailboxes = Mailbox.order(:mailbox)
mailboxes.keep_if do |mailbox|
  # test
end

in Rails 4.1.0 it break with

相关标签:
1条回答
  • 2020-12-17 10:07

    Its in release notes for rails 4.1

    Relation no longer has mutator methods like #map! and #delete_if. Convert to an Array by calling #to_a before using these methods. (Pull Request)

    Since keep_if is a mutator method, its removed from Relation

    0 讨论(0)
提交回复
热议问题