Closed ryancheung closed 11 years ago
I manually added the help to the controller and then the issue is gone.
I have a looking similar issue here.
After defining gem 'activeadmin-axlsx'
in Gemfile
, my Rails application's controllers can't use custom helpers which previously worked well. I tried helper :all
in ApplicationController that all other controllers inherit, it didn't work and I had to specify helpers I needed one by one.
I don't know much about how helpers are included, but it looks that activeadmin-axlsx gem affects the mechanism.
Maybe re-open this issue?
I have also met this problem, and I tried to solve it, but unfortunately I failed.
So here's what I have done:
First, I cloned this gem into my local filesystem, and used my local version of this gem in my Gemfile. Since I don't really understand what's happening here, I started to comment out lines, in order to locate the problematic line of code.
So, I've found it is this line that causes the problem: Once I commented this line out, my helpers are automatically loaded (Though this gem did not work, I suppose).
Since it mixes a module into ActiveAdmin::ResourceController, I dug into this line, which lead me to resource_controller_extension.rb, and I commented these lines out, which made ActiveAdmin::Axlsx::ResourceControllerExtension
an empty module. But my helpers are still not loaded!
In order to make sure that nothing in somewhere else magically adds stuff into the module, I changed the file into this:
# require 'active_admin'
# require 'active_admin/axlsx/version'
# require 'active_admin/axlsx/builder'
# require 'active_admin/axlsx/dsl'
# require 'active_admin/axlsx/resource_extension'
require 'active_admin/axlsx/resource_controller_extension'
class Railtie < ::Rails::Railtie
config.before_initialize do
# begin
# if Mime::Type.lookup_by_extension(:xlsx).nil?
# # The mime type to be used in respond_to |format| style web-services in rails
# Mime::Type.register "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", :xlsx
# end
# rescue NameError
# # noop
# end
# ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::Axlsx::DSL
# ActiveAdmin::Resource.send :include, ActiveAdmin::Axlsx::ResourceExtension
# Problematic Line
# ActiveAdmin::ResourceController.send :include, ActiveAdmin::Axlsx::ResourceControllerExtension
module Foobar
end
ActiveAdmin::ResourceController.send :include, Foobar
# ActiveAdmin::Views::PaginatedCollection.add_format :xlsx
end
end
and it will still prevent my helpers from auto-loading! Once I comment ActiveAdmin::ResourceController.send :include, Foobar
out, my helpers would just be back, magically.
I tried to mix an empty module in in an initializer in my Rails application, it won't affect anything.
The rest of this problem is beyond my knowledge, does anyone have any ideas?
Fixed it in this pull-request.
I got a register_page Dashboard:
The
order_state
is a custom helper inapp/helpers/orders_helper.rb
. It would not work after I added this gem to Gemfile. I checked theactiveadmin
repo and found it's usemethod_missing
to find a helper, but It just can't find out the helper from@helpers
in pry debugging. More seriously, it cause infinit loop, which means the server stucked and cpu/memory is in high usage.