The Wizard
The Wizard

Reputation: 953

Rails bundler change branch of gem depending on environment

I am trying to use a different branch in my Gemfile.rb depending on the Rails environment. Is this possible?

I have tried the following, but the branch is always branch_B regardless of environment:

branch = 'branch_A'
group :production do
  branch = 'branch_B'
end
gem 'gem_name', git:'git_url', branch: branch

Upvotes: 0

Views: 237

Answers (1)

See if this helps

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

In terminal, you'll have to run

RAILS_ENV=development bundle

Upvotes: 2

Related Questions