0
我想查詢以下NoMethodError:未定義的方法`名」爲:賬號:符號
Vehicle.where(:account.name => "").count
,我得到這個錯誤:
NoMethodError: undefined method `name' for :account:Symbol
車輛和客戶之間的關聯一直在模型上定義和我用戶約定。爲什麼我會得到這個錯誤?
Vehicle.rb
class Vehicle < ActiveRecord::Base
belongs_to :account
end
Account.rb
class Account < ActiveRecord::Base
has_many :vehicles
end
架構
create_table "accounts", force: true do |t|
t.string "name"
...
end
create_table "vehicles", force: true do |t|
t.integer "account_id"
...
end
我得到這個錯誤香> PG :: UndefinedTable:錯誤:缺少FROM子句條目表 「帳戶」 LINE 1: 「 」...... nt_id」和「 賬戶deleted_at」 IS NULL WHERE( account.wf ... – Lut
已更新 - 使用表格名稱複數 – Shannon
我仍然收到一個錯誤:在Vehicle上找不到名爲'accounts'的協會;也許你拼錯了嗎? – Lut