Skip to content

ActiveAdmin, Spork, and the infamous “undefined local variable or method `view_factory'”

January 31, 2012

If you are using ActiveAdmin and you are also using Spork as part of your testing suite you are probably extremely frustrated with an error that looks something like this:

ActionView::Template::Error: undefined local variable or method `view_factory' for #<#Class:0x000001070ccf80:0x000001070c7648>

This issue has been queued and is discussed further here:

Your solution is simple.  Just add the following to your test/test_helper.rb:

Spork.each_run do
  ActionView::Template.register_template_handler :arb, lambda { |template|
    "self.class.send :include, Arbre::Builder; @_helpers = self; self.extend ActiveAdmin::ViewHelpers; @__current_dom_element__ =, self); begin; #{template.source}; end; current_dom_context"

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: