activeadmin: Custom controller actions rendering error

Rendering is causing the following error on my member controller action on Rails 3.1.3 with the latest active_admin code form github:

undefined method `get' for nil:NilClass

The error is coming from this call in layout.rb:

1: render view_factory.layout

and traces back to the content_for method in ActionView::Helpers::CaptureHelper:

def content_for(name, content = nil, &block)
  if content || block_given?
    content = capture(&block) if block_given?
    @view_flow.append(name, content) if content
    nil
  else
    @view_flow.get(name) # THIS IS WHAT IS TRIGGERING THE NIL ERROR
  end
end

This issue is that @view_flow is nil, so when content_for(:layout) is being called, @view_flow.get(:layout) fails with a nil error.

I cannot figure out why @view_flow is nil or how to remedy this issue. I have tried ERB, ARB, and HAML templates for my member action but to no avail. For the sake of completeness below are the first few lines of the backtrace:

activesupport (3.1.3) lib/active_support/whiny_nil.rb:48:in `method_missing'
actionpack (3.1.3) lib/action_view/helpers/capture_helper.rb:142:in `content_for'
/active_admin/lib/active_admin/views/pages/layout.rb:17:in `main_content'
/active_admin/lib/active_admin/views/pages/base.rb:116:in `block (2 levels) in build_main_content_wrapper'
/active_admin/lib/active_admin/arbre/builder.rb:68:in `block in build_tag'

About this issue

  • Original URL
  • State: closed
  • Created 13 years ago
  • Comments: 44 (13 by maintainers)

Commits related to this issue

Most upvoted comments

In my case, the problem was caused by a similar include in the global namespace

include ActionView::Helpers::TextHelper

Removing this include solved the problem…

Did anyone find a solution for this?