型号麻烦
问题描述:
我 customer.rb型号麻烦
class Customer < ActiveRecord::Base
acts_as_authentic
has_many :credit_cards
has_many :telephones
has_many :virtual_pays
end
telephone.rb
class Telephone < ActiveRecord::Base
belongs_to :customers
end
当我使用的轨道控制台广告写Customer.all,我会得到从数据库表中的所有数据客户,但是当我尝试获取所有数据包括客户电话我得到错误 我写:customers.telephones.all,然后我尝试Customer.Telephone.all,但如何正确地做到这一点?
NameError: undefined local variable or method
customers' for main:Object from (irb):6 from /home/pp/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands/console.rb:44:in
start' from /home/pp/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands/console.rb:8:instart' from /home/pp/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.0.9/lib/rails/commands.rb:23:in
' from script/rails:6:inrequire' from script/rails:6:in
'
另外我正确的写模型?
你想知道如何查询客户的电话号码吗? – 2012-04-12 20:11:56
其实是的.... – byCoder 2012-04-12 21:12:54