我 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