activeadmin自定义呈现,如果

编程入门 行业动态 更新时间:2024-10-08 04:24:49
本文介绍了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

显示

/home/amol/.rvm/ gems/ruby-1.9.2-p290@xxx/gems/activeadmin-0.5.0/app/views/layouts/active_admin.html.arb 其中第1行出现:

/home/amol/.rvm/gems/ruby-1.9.2-p290@xxx/gems/activeadmin-0.5.0/app/views/layouts/active_admin.html.arb where line #1 raised:

未定义方法'base':NilClass

undefined method `base' for nil:NilClass

提取的源代码(#1行附近):

Extracted source (around line #1):

1: insert_tag view_factory.layout

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

any idea? whats happening here. Stack trace is not pointing to any of my written code file.

我想在这里显示的是如果存在@topic,那么我想渲染我的视图否则为默认值。

What I want here is, if @topic is present then I want to render my view else the default one.

推荐答案

我在这种情况下正在调用 super 作为控制器操作的最后一行。

I have this scenario working calling to super as the last line in the controller action.

Super会为您呈现默认视图。

Super will render the default view for you.

更多推荐

activeadmin自定义呈现,如果

本文发布于:2023-11-28 04:34:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640983.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   activeadmin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!