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