0
我想呈現一個JSON對象包含商店(模型:商店)的列表。用戶與商店有關聯,但是每個用戶在每個商店都有唯一的可用點數供使用。找點可用於商店或總數的表達式爲:Rails活動記錄字段,動態值(評估)
@user.codes.unspent.find_all_by_store_id(@store.id).count
# unspent is a scope
# @user is the currently logged in user
# Code model keeps all activity records of points.
因爲我使所有門店的JSON對象列表,上面表達顯然不是在商店數據庫中的字段,如何我可以評估這個表達式並返回每個商店的計數嗎?
此外,什麼是性能影響?
謝謝。
你應該呈現自己的js.erb文件 – apneadiving 2011-01-30 21:13:25