activeadmin自定义渲染如果



我的下面代码

ActiveAdmin.register Question do
  belongs_to :topic, :optional => true
  controller do
    def index
      @topic = Topic.find_by_id params[:topic_id]
      if @topic
        @questions = @topic.questions
        render 'settings/questions/_by_admin', :layout => 'active_admin'
        return
      end
    end
  end
end

投掷

 NoMethodError in Admin/questions#index

显示

在 其中#1列出的地方:

未定义的方法nil:nilclass

提取的源(周围#1):

1: insert_tag view_factory.layout

有什么想法吗?这里发生了什么事。堆栈跟踪没有指向我的任何书面代码文件。

我想要的是,如果存在@topic,那么我想渲染我的视图否则默认一个。

我有此场景可用来呼叫super作为控制器操作中的最后一行。

超级将为您渲染默认视图。

相关内容

最新更新