.gemrc file specification

gem looks for a configuration file .gemrc in your home directory, although you can specify another file on the command-line if you wish (with the –config-file modifier). There are three things you can specify in the configuration file: command-line arguments to be used every time gem runs command-line options for ’’RDoc’’ (used when generating documentation) … Read more

Installing Ruby gems not working with Homebrew

Homebrew is nice. However unlike brew and npm, gem does not make aliases in /usr/local/bin automatically. Solution I went for a very simple approach (as of March 2020): # Based on “`brew –prefix ruby`/bin” export PATH=/usr/local/opt/ruby/bin:$PATH # Based on “`gem environment gemdir`/bin” export PATH=/usr/local/lib/ruby/gems/3.0.0/bin:$PATH Add this to your .bashrc (or .bash_profile, .zshrc, etc.). That’s it! … Read more

Download all gems dependencies

That’s precisely the problem I had. After searching around for a while I found a solution that works using Bundler https://bundler.io/ Getting Gem with Dependencies: Create a new Folder with a File named Gemfile. Write a Source and the Gem you want to have the dependencies for into the File Example: source “http://rubygems.org” gem ‘rails’, … Read more

Why “bundle install” a gem instead of “gem install” for a rails 3 app?

Using bundler instead of gem command to directly install your gems gives you a whole lot of benefits. In this specific case where you suggest using the gem command to install and adding it later to the Gemfile, bundler will resolve all the dependencies for you when you install a gem, which you might have … Read more

how to require active record working outside of rails

Here’s how I’m using ActiveRecord outside of Rails: #!/usr/bin/ruby require ‘active_record’ require ‘mysql2’ # or ‘pg’ or ‘sqlite3’ ActiveRecord::Base.establish_connection( adapter: ‘mysql2’, # or ‘postgresql’ or ‘sqlite3’ database: ‘DB_NAME’, username: ‘DB_USER’, password: ‘DB_PASS’, host: ‘localhost’ ) # Note that the corresponding table is ‘orders’ class Order < ActiveRecord::Base end Order.all.each do |o| puts “o: #{o.inspect}” end

tech