本文介绍了阻止assert_valid_keys“:未知的关键:为了(时ArgumentError)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我运行轨道4.1.0.rc2和我得到了引发ArgumentError 块assert_valid_keys:未知的关键:为了
当我尝试做的:
I'm running rails 4.1.0.rc2 and I'm getting the ArgumentError block in assert_valid_keys': Unknown key: :order
when I try to do:
has_many :workout_exercises, dependent: :destroy, order: "exercise_order DESC"`
我想提出一个订单约束我的加盟模式,而据我所知,这曾与Rails的3.2,所以我也弄不清是怎么回事。有任何想法吗?
I want to put an order constraint on my join model, and as far as I can tell, this worked with Rails 3.2, so I can't figure out what is going on. Any ideas?
推荐答案
试试这个:
has_many :workout_exercises, dependent: :destroy,-> { order "exercise_order desc" }
更新,按OP的评论(重排指令):
Update, as per OP's comment (reorder the directives):
has_many :workout_exercises,-> { order "exercise_order desc" }, dependent: :destroy
这篇关于阻止assert_valid_keys“:未知的关键:为了(时ArgumentError)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!