Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 在RABL中显示parent.name而不是parent.id_Ruby On Rails 4_Rabl - Fatal编程技术网

Ruby on rails 4 在RABL中显示parent.name而不是parent.id

Ruby on rails 4 在RABL中显示parent.name而不是parent.id,ruby-on-rails-4,rabl,Ruby On Rails 4,Rabl,我有一个RABL文件: collection :@points attributes :id, :point_type, :name, :coordinates child :point_pages do attributes :point_page_type child :point_page_classes do attributes :auto_class_id, :show_price # I need to change this line end end 因

我有一个RABL文件:

collection :@points
attributes :id, :point_type, :name, :coordinates
child :point_pages do
  attributes :point_page_type
  child :point_page_classes do
    attributes :auto_class_id, :show_price   # I need to change this line
  end
end
因此,
point\u page\u类属于:point\u page
属于:auto\u类

我需要在
point\u page\u class
属性中显示的不是
auto\u class
id
,而是它的
name
。但是,当然,在DB中的
point\u page\u classes
表中,我只有
auto\u class\u id

我需要像这样的东西:

child :point_page_classes do
  attributes AutoClass.find(auto_class_id).name, :show_price
end

谢谢你的帮助

胶水
方法:

collection :@points
attributes :id, :point_type, :name, :coordinates
child :point_pages do
  attributes :point_page_type
  child :point_page_classes do
    attributes :show_price
    glue(:auto_class) do
      attributes :name
    end
  end
end