使用RefineryCMS和ActiveRecord查找特定页面的子项

时间:2014-07-25 18:09:55

标签: ruby-on-rails ruby activerecord refinerycms

现在我有一个带有自定义模板的页面。

我想在过滤器之前使用装饰器,如页面装饰器中那样:

before_filter :get_gallery_index, :only => [:gallery_main]

要定义此方法,我想声明类似于:

的内容
  def get_gallery_index
    # a = Refinery::Page.where(id: 6).children <- would be ideal
  end

当然,儿童不是使用Refinery Pages和ActiveRecord的有效方法。有没有人建议我如何获得这些记录?

1 个答案:

答案 0 :(得分:0)

通过搜索parent_id得到它:

def get_gallery_index   @gallery_index = Refinery :: Page.where(:parent_id =&gt; 6) 端