我生成了兩個腳手架:信用卡和信用點核心。Rails:如何從不同的模型中獲得價值
- 用戶和信用卡之間有一個has_many關聯。
- 用戶和creditcore之間有一個has_one關聯。
在creditcards credits.html.erb視圖中,我試圖顯示來自creditscore模型的current_user分數。
這裏就是我試圖把在creditcards_controller.rb:
def credits
@creditscores = Creditscore.find_all_by_user_id current_user[:id] if current_user
@creditscore = current_user.creditscore
end
而且在credits.html.erb觀點:
<%= creditscore.score %>
這裏的錯誤:
undefined local variable or method `creditscore' for #<#<Class:0x00000101a69558>:0x00000101a68680>
我是個白癡。謝謝 – beaconhill