0
我正在使用Rails 2.3.11。我有2級表的客戶和職位:錯誤NoMethodError(未定義方法'+'爲ActiveRecord :: Associations :: BelongsToAssociation:0xb6c9b45c)
# Table name: customers
# id :integer(4) not null, primary key
# Name ::string(255) default("Anonymous")
...
class Customer < ActiveRecord::Base
has_many :posts
...
# Table name: posts
# id :integer(4) not null, primary key
# customer_id :integer(4)
...
class Post < ActiveRecord::Base
belongs_to :customer
...
在我posts_controller,我想回到一個GET調用的XML響應,相應的後交與客戶的詳細信息。
@customer = Customer Details
@posting = Corresponding Post
以下行引發錯誤NoMethodError (undefined method '+' for ActiveRecord::Associations::BelongsToAssociation:0xb6c9b45c)
:
respond_to do |format|
format.xml { render :xml => (@customer + @posting)}
這看起來是一個很瑣碎的問題,我在這裏缺少一些基本知識。有人能幫我理解這個錯誤嗎?