简体   繁体   中英

ActiveAdmin uninitialized constant in Ruby on Rails

I get the following error after deploying my application in ec2.

Active Admin works fine on my local development environment, but once I deploy using docker, it looks like the gem is not being installed.

If I check using bundler show activeadmin it shows Active Admin is installed.

My gem file is:

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

I searched this problem, added require 'activeadmin' to my active_admin.rb initializer and it doesn't work.

I'm using:

  • Ruby v2.2.0
  • Rails v4.2.2

When I deploy in docker My error Message

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

when i added 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 中修复它

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM