Rake Assets在开发或测试组中不使用Gems进行预编译

Ale*_*ham 7 ruby rake gem ruby-on-rails ruby-on-rails-4

好的,所以我在构建Docker镜像时遇到了错误(想想它类似于部署步骤,或者如果你不熟悉Docker则进行Heroku部署).

当预编译步骤发生时,正在查找:test:development组中的宝石,并且因为我已经捆绑--without development test- 因为我不想让QT只是因为capybara-webkit没有错误在bundle上 - 预编译步骤会抛出一个错误.

该错误始终是以下变体:

Could not find <gem-name> in any of the sources (Bundler::GemNotFound)
Run Code Online (Sandbox Code Playgroud)

我的Gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.9'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# 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 https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# 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

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'
gem 'unicorn', '~> 4.8.3'
gem 'unicorn-worker-killer', '~> 0.4.2'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

gem 'rdf', '~> 1.1.0'
gem 'tripod', '~> 0.11.1'

gem 'devise'
gem 'devise_invitable'
gem 'authority'
gem 'mongoid', '~> 4.0.0'

gem 'bootstrap-sass', '~> 3.3.3'

# pagination
gem 'kaminari', '~> 0.16.3'
gem 'bootstrap-kaminari-views'

# background processing
gem 'sidekiq'
gem 'sidekiq-status'
gem 'request_store', '~> 1.1.0'

# add memoization
gem 'memoist', '~> 0.12.0'

# dropbox gem for uploads etc
gem 'dropbox-sdk', '~> 1.6.4'

# error reporting
gem 'sentry-raven'

group :development, :test do
  gem "rspec-rails", "~> 3.0.0"
  gem "factory_girl_rails", "~> 4.5.0"
  gem "capybara", "~> 2.4"
  gem "database_cleaner"
  # gem "selenium-webdriver"
  gem 'poltergeist'
  gem 'capybara-webkit'

  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  #gem 'byebug'
  gem 'pry-byebug'
  gem 'better_errors', '~> 2.1.1'

  # 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
Run Code Online (Sandbox Code Playgroud)

Dockerfile发生错误的位置是:

RUN /bin/bash -l -c "RAILS_ENV=production bundle exec rake assets:precompile RAILS_GROUPS=assets --trace"
Run Code Online (Sandbox Code Playgroud)

基本上,我真正追求的是--without test developmentrake任务的等价物.我能这样做吗?根据一些建议,我已经改变了(in application.rb):

Bundler.require(*Rails.groups)
Run Code Online (Sandbox Code Playgroud)

Bundler.require(:default, :assets, Rails.env)
Run Code Online (Sandbox Code Playgroud)

任何人都有Rails-fu足以解决这个问题?我已经查看了文档和SO,以及询问我的同事,但我还在敲打着我的头撞墙.

Abh*_*ddy 1

bundle install --path vendor/cache
Run Code Online (Sandbox Code Playgroud)

试试这个,如果不起作用请告诉我!