在 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
# 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)