Ruby on rails 具有nil集合的RABL模板

Ruby on rails 具有nil集合的RABL模板,ruby-on-rails,rabl,Ruby On Rails,Rabl,我有以下RABL模板文件 node(:status) { response.status } node(:errors) { @errors.inspect } collection :@substances attributes :name 现在我的控制器操作实际上没有被调用,因为身份验证过滤器正在运行,并将返回状态设置为401。所以@物质是零。然后,RABL以失败告终 undefined method `name' for nil:NilClass 错误。我如何才能让RABL在集合为

我有以下RABL模板文件

node(:status) { response.status }
node(:errors)  { @errors.inspect }

collection :@substances
attributes :name
现在我的控制器操作实际上没有被调用,因为身份验证过滤器正在运行,并将返回状态设置为401。所以@物质是零。然后,RABL以失败告终

undefined method `name' for nil:NilClass

错误。我如何才能让RABL在集合为零时不开始迭代它?

没有找到解决此问题的最终解决方案。我们现在切换到DHH的JBuilder,它有更好的语法和更多的可能性imho。现在一切都好了。。