我想作這樣的事:導軌 - 如何將對象添加到一個變量
@profiles
#(I think in Java, so I have declared an @profiles variable there! I know it's probably wrong!)
@users.each do |user|
profile = Profile.find(params[user.id])
@profiles.add(profile)
end
的用戶配置文件中有一個一對一的關係。
用戶配置文件, 輪廓屬於用戶
你還沒有「聲明」一個'@ profiles'變量存在。你只是試圖查找那個實例變量,並且因爲它不存在,所以該行的計算結果爲'nil'。 – d11wtq 2011-12-18 04:32:59