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