本文介绍了在Gemfile中设置环境,以根据自定义文件捆绑安装/更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 所有我建立一个sinatra应用程序,捆绑的主要文件如下, environment.rb require'sinatra' require'sequel' ENV ['RACK_ENV'] ='development' configure:production do #do something end configure:development,:test do #do something end Gemfile gem'sinatra' gem'sequel' gem'pg',:group => :制作 gem'sqlite3',:group => [:development,:test] 所以,如何让这个bundle基于ENV [' RACK_ENV']在我的environment.rb文件中。解决方案在做捆绑器需求时,您可以指定需要哪些组。 / p> 例如: require'rubygems' require 'bundler' 如果ENV ['RACK_ENV'] =='development' Bundler.require(:default,:development) else Bundler.require( :默认)需要'sinatra' 更多关于bundler网站gemfile规格的信息这里。 hi, allI build a sinatra app, the main files for bundling as the following,environment.rbrequire 'sinatra'require 'sequel'ENV['RACK_ENV'] = 'development'configure :production do #do somethingendconfigure :development, :test do #do somethingendGemfilegem 'sinatra'gem 'sequel'gem 'pg', :group => :productiongem 'sqlite3', :group => [:development, :test]So, how to let the bundle install based on the ENV['RACK_ENV'] in my environment.rb file. 解决方案 When doing a bundler require you can specify which groups to be required.For example:require 'rubygems'require 'bundler'if ENV['RACK_ENV'] == 'development' Bundler.require(:default, :development)else Bundler.require(:default)require 'sinatra'More info on the bundler site gemfile specifications found here. 这篇关于在Gemfile中设置环境,以根据自定义文件捆绑安装/更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-30 07:52