我的下面的代码
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自定义呈现,如果
发布评论