由网友(别再辜负我了)分享简介:在Rails的4.0.4本code的工作:in Rails 4.0.4 this code work:mailboxes = Mailbox.order(:mailbox)mailboxes.keep_if do |mailbox|# testend在Rails的4.1.0用 NoMethodError突破(未...
在Rails的4.0.4本code的工作:
in Rails 4.0.4 this code work:
mailboxes = Mailbox.order(:mailbox)
mailboxes.keep_if do |mailbox|
# test
end
在Rails的4.1.0用 NoMethodError突破(未定义的方法keep_if为<邮箱:: ActiveRecord_Relation:0x5494f80>)
in Rails 4.1.0 it break with NoMethodError (undefined method keep_if for <Mailbox::ActiveRecord_Relation:0x5494f80>)
和已被改变,以
mailboxes = Mailbox.order(:mailbox).to_a
mailboxes.keep_if do |mailbox|
# test
end
我没有找到有关的任何信息。
I don't find any information about that
你知道吗?
推荐答案
及其release说明钢轨4.1
关联不再具有突变的方法,如#map!和#delete_if。 通过调用#to_a使用这些方法之前转换成一个阵列。 (拉 请求)
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)
由于 keep_if
是一个赋值函数方法,它从关联删除
Since keep_if
is a mutator method, its removed from Relation
相关推荐
最新文章