在可安装的发动机内安装导轨ActiveAdmin发动机

时间:2012-01-03 20:28:16

标签: ruby-on-rails ruby-on-rails-3 activeadmin rails-engines

我试图在可安装的引擎中安装rails active admin gem,但在运行虚拟app服务器时遇到以下错误 -

     /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:25:in `stat': No such file or directory - /mycode/testingengine/app/admin (Errno::ENOENT)
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:25:in `block in updated_at'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:25:in `map'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:25:in `updated_at'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/file_update_checker.rb:29:in `execute_if_updated'
from /.rvm/gems/ruby-1.9.2-p290/gems/activeadmin-0.3.3/lib/active_admin/reloader.rb:22:in `block in attach!'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:404:in `_run_prepare_callbacks'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.1.1/lib/action_dispatch/middleware/reloader.rb:46:in `prepare!'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `instance_exec'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:30:in `run'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:55:in `block in run_initializers'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `each'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/initializable.rb:54:in `run_initializers'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:96:in `initialize!'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /mycode/testingengine/config/environment.rb:5:in `<top (required)>'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `block in require'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `block in load_dependency'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:640:in `new_constants_in'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:223:in `load_dependency'
from /.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:240:in `require'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:83:in `require_environment!'
from /.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:22:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

任何人都知道如何解决这个问题?我运行了rails g active_admin:安装在父可安装引擎目录中,文件夹/ mycode / testingengine / app / admin确实存在默认仪表板文件,所以我不知道从哪里开始。任何帮助非常感谢!

2 个答案:

答案 0 :(得分:0)

终于明白了。在ActiveAdmin.setup initalizer块中添加以下内容。

    config.load_paths.delete_at(0)
    config.load_paths << "#{Cms::Engine.root}/app/admin/"

请务必使用引擎名称替换Cms。现在它不会尝试使用您的引擎文件夹从应用程序加载activeadmin。

答案 1 :(得分:0)

如果在父引擎中配置了ActiveAdmin,并且不希望通过引用子应用程序来混淆父应用程序中的配置,则可以在可安装引擎中设置ActiveAdmin加载页面:

module YourEngine
  class Engine < ::Rails::Engine

    # ...

    initializer :divery do |app|
      ActiveAdmin.application.load_paths << File.join(config.root, 'lib/admin')
    end

    # ...

  end
end

请注意,您的ActiveAdmin资源在app/all admin resources should be defined in lib中定义 非常重要。