ruby-on-rails - Ruby on Rails 中的 ActiveAdmin 未初始化常量

标签 ruby-on-rails docker activeadmin

在 ec2 中部署我的应用程序后,我收到以下错误。

Active Admin 在我的本地开发环境中运行良好,但是一旦我使用 docker 部署,看起来 gem 没有被安装。

如果我使用 bundler show activeadmin 检查它显示安装了 Active Admin。

我的 gem 文件是:

gem 'rails', '4.2.2'

gem 'mysql2', "~> 0.3.20"
# Use SCSS for stylesheets
gem 'sass-rails', '>= 3.2'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See htt                                                              
gem 'bcrypt', '3.1.7'
gem 'bootstrap-sass'
gem 'roo', '2.0.0'
gem 'iconv'
gem 'roo-xls'
gem 'omniauth-facebook'
gem 'omniauth'
gem 'fancybox-rails'
gem 'will_paginate'
gem 'bootstrap-will_paginate', '0.0.10'

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'unicorn'

gem 'yaml_db'

gem 'figaro'

gem 'execjs'
gem 'therubyracer'

gem 'devise'
gem 'activeadmin', github: 'gregbell/active_admin'

gem 'rollbar', '~> 2.8.3'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
end

我搜索了这个问题,加了require 'activeadmin'到我的 active_admin.rb 初始化程序,它不起作用。

我正在使用:
  • ruby v2.2.0
  • Rails v4.2.2

  • 当我在 docker 中部署时
    我的错误信息
    NameError: uninitialized constant ActiveAdmin
    /app/config/initializers/active_admin.rb:1:in `<top (required)>'
    /app/config/environment.rb:5:in `<top (required)>'
    Tasks: TOP => environment
    (See full trace by running task with --trace)
    

    文件
    # Dockerfile
    FROM seapy/rails-nginx-unicorn-pro:v1.0-ruby2.2.0-nginx1.6.0
    MAINTAINER seapy(iamseapy@gmail.com)
    
    # Add here your preinstall lib(e.g. imagemagick, mysql lib, pg lib, ssh config)
    RUN apt-get update
    RUN apt-get install -qq -y mysql-server mysql-client libmysqlclient-dev
    
    
    #(required) Install Rails App
    ADD Gemfile /app/Gemfile
    ADD Gemfile.lock /app/Gemfile.lock
    RUN bundle install --without development test
    RUN bundle update
    ADD . /app
    
    #(required) nginx port number
    EXPOSE 80
    

    当我添加 require 'activeadmin'
    rake aborted!
    /opt/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/orm_adapter-0.5.0/lib/orm_adapter/adapters/active_record.rb:81: warning: already initialized constant ActiveRecord::Base::OrmAdapter
    /opt/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/orm_adapter-0.5.0/lib/orm_adapter/adapters/active_record.rb:81: warning: previous definition of OrmAdapter was here
    NoMethodError: undefined method `default_timezone=' for #<Class:0x007ff5e0f92008>
    /app/config/initializers/active_admin.rb:1:in `<top (required)>'
    /app/config/environment.rb:5:in `<top (required)>'
    Tasks: TOP => environment
    (See full trace by running task with --trace)
    

    最佳答案

    在 config/environments/production.rb config.assets.compile = true 中修复它

    关于ruby-on-rails - Ruby on Rails 中的 ActiveAdmin 未初始化常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36921097/

    相关文章:

    ruby-on-rails - 使用 RSpec 验证部分参数

    ruby-on-rails - Rails 和 I18n : localized templates vs localized string

    ActiveAdmin - 如何自定义编辑操作?

    ruby-on-rails - 从 Active Admin 过滤器向 Ransack 发送参数

    ruby-on-rails - 问题是由于 "accepts_nested_attributes_for"和 "has_many through"关系而发生的,它给出了 not id found error with factory_girl 和 rspec

    ruby-on-rails - Rails成员(member)路线

    mongodb - Docker内部mongo中的shell命令无法进行身份验证

    amazon-web-services - 在使用自定义 docker 镜像初始化 pytorch 估计器以在 AWS Sagemaker 上进行训练时,将什么定义为入口点?

    scala - OCI错误 “/opt/docker/bin/my_job”:使用sbt docker:publishLocal没有此类文件或目录

    ruby-on-rails - Rails 3 事件管理员。如何在 Active Admin 中的搜索中为六列使用一个字段?