gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 14:10:57 25 4
gpt4 key购买 nike

在 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/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com