[英]undefined method `reorder' for active admin
我正在嘗試為我的模型之一在活動管理中使用作用域,並且出現此error undefined method reorder' for array.
我已經在具有活動admin的另一個模型中成功使用了范圍,但是我無法調試為什么會出現此問題。
這是來自活動管理員的代碼:-
ActiveAdmin.register Startup do
scope :reached do |startups|
startups.all
end
end
任何想法可能是什么問題?
您返回的是數組而不是ActiveRecord關系,我的猜測是您試圖將其鏈接到無法正常工作的.order
類的方法。 您打算做什么?
如果只需要所有記錄,則不需要范圍。 如果您想縮小創業公司的范圍,則應該使用類似Startup.where(#condition you want met)
這是我在模型級別的關聯。
在startup.rb中
has_many :fund_requests, :dependent => :destroy
在fund_request.rb中
belongs_to :startup
我試圖在達到狀態(資金請求中的屬性)的范圍內划定資金請求。
但是這樣的事情在模型級別上有效,不適用於活動管理員
scope :reached do |startups|
startups.fund_requests.where(status = ?', 'Pending')
end
這給了我“重新排序”錯誤
像這樣寫對我有用:-
scope :reached do |startups|
startups.joins(:fund_requests).where(['fund_requests.status = ?', 'Pending'])
end`
我不知道為什么鏈接不起作用而聯接卻起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.