我正在我的應用程序時,面臨着這樣的SQLite的異常錯誤:的SQLite3 ::的SQLException:在軌道沒有這樣的列4.2.6
SQLite3::SQLException at /admin
no such column: subscription_plan.name
這是控制器代碼,我面對錯誤:
def dashboard
@number = {
:month => Subscription.includes(:subscription_plan).where(['subscriptions.created_at > ? AND subscriptions.amount > ? AND subscription_plan.name = ?', Time.zone.now.beginning_of_month, 0, 'month']).count,
:year => Subscription.includes(:subscription_plan).where(['subscriptions.created_at > ? AND subscriptions.amount > ? AND subscription_plan.name = ?', Time.zone.now.beginning_of_month, 0, 'year']).count
}
end
這是訂閱模式與關係:
class Subscription < ActiveRecord::Base
belongs_to :subscription_plan
end
有一個在我的APPLI沒有subscription_plan模型但是該表中的數據通過seeds.rb文件填充。 如控制器所示,'month','year'是subscription_plan表中的一些名稱。
它正常工作與Rails 3.2,我不知道爲什麼它不與4.2.6工作。請幫忙。
表名稱可能是subscription_plans,嘗試subscription_plans.name =? – power
是的,表名是subscription_plans,即使它不工作。我不知道如何,在以前的版本中他們也是這樣做的,它工作。 –
嘗試在最後添加引用(:subscription_plans),這在我的答案中提到。 – power