我有这个模板:
# app/views/posts/index.rabl collection @posts => :posts attributes :id,:title,:subject child(:user) { attributes :full_name } node(:read) { |post| post.read_by?(@user) }
女巫返回:
{ "posts": [ { "post": { "id": 5,"title": "...","subject": "...","user": { "full_name": "..." },"read": true } } ] }
{ "posts": [ { "post": { "id": 5,"read": true } } ],"total": 42,"total_pages": 12 }
有任何想法吗?非常感谢!