我有这样的 index.rabl:
collection @exchangers, :root => "bank", :object_root => false
extends "exchanger_lists/show"
和这样的show.rabl:
object @exchanger
attributes :id, :name, :address, :location_id, :latitude, :longitude, :exchanger_type_id
node(:location_name) {|exchanger_list| exchanger_list.location.name }
node(:exchanger_type_name) {"normal" }
child @currencies do
attribute :value, :direction_of_exchange_id, :exchanger_list_id
end
我的控制器是这样的:
def index
@exchangers = ExchangerList.all
end
def show
@exchanger = ExchangerList.find(params[:id])
@currency_list = CurrencyList.all
@currencies = []
@currency_list.each do |c|
@currencies << CurrencyValue.find(:all, :conditions => {:currency_list_id => c.id, :exchanger_list_id => @exchanger.id}, :order => :updated_at).last(2)
end
@currencies.flatten!
end
如果我在浏览器显示方法中调用,我会看到子 @currencies 和它的数据,但是如果我调用索引,我会看到所有(我也看到节点),但我没有看到子项....怎么了?我做错了什么?