问题
My below code
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
is throwing
NoMethodError in Admin/questions#index
Showing
/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:
undefined method `base' for nil:NilClass
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.
What I want here is, if @topic is present then I want to render my view else the default one.
回答1:
I have this scenario working calling to super
as the last line in the controller action.
Super will render the default view for you.
来源:https://stackoverflow.com/questions/13116244/activeadmin-custom-render-if