我试图根据Rails环境在Gemfile.rb中使用其他分支。这可能吗?
我尝试了以下方法,但是无论环境如何,分支始终为branch_B:
branch = 'branch_A'
group :production do
branch = 'branch_B'
end
gem 'gem_name', git:'git_url', branch: branch
答案 0 :(得分:1)
看看这是否有帮助
def branch
if ENV["RAILS_ENV"] == "production"
@branch = 'branch_B'
puts "I'm in production"
else
@branch = 'branch_A'
puts "I'm in development"
end
end
gem 'sqlite3', branch: branch
在终端中,您必须运行
RAILS_ENV=development bundle