0
在我的控制器:Rails的:「你有一個零對象時,你沒想到吧」
Article.author_ids_in(params[:filters][:author_ids])
這當然返回如果這些錯誤(「你有一個無對象...」)特定的參數尚未通過。下面是該模型的方法:
def self.author_ids_in(filters)
unless filters.nil?
where(:author_id + filters)
else
scoped
end
end
正如你所看到的,我已經爲nil對象準備,所以我怎麼能得到紅寶石允許零傳遞?
你確定你的'params [:filters]'不是'nil'嗎?請給出完整的錯誤信息。 –