Unable to install gem – Failed to build gem native extension – cannot load such file — mkmf (LoadError)

Ruby 1.9.3 The part of Gemfile #…………… gem “pony” gem “bcrypt-ruby”, :require => “bcrypt” gem “nokogiri” #……………… When I’m trying to install gems, I get an error alex@ubuntu:~/$ bundle Fetching gem metadata from http://rubygems.org/……… Fetching gem metadata from http://rubygems.org/.. Enter your password to install the bundled RubyGems to your system: #####…………………………………………………… Installing bcrypt-ruby (3.0.1) with … Read more

Ignoring GEM because its extensions are not built

On both my work and home computers, I recently upgraded Ruby to 2.3.1, using ruby-install. I use chruby as my Ruby switcher. I started seeing this warning in my terminal: Ignoring bcrypt-3.1.11 because its extensions are not built. Try: gem pristine bcrypt –version 3.1.11 Ignoring bcrypt-3.1.10 because its extensions are not built. Try: gem pristine … Read more

What is the canonical way to trim a string in Ruby without creating a new string?

This is what I have now – which looks too verbose for the work it is doing. @title = tokens[Title].strip! || tokens[Title] if !tokens[Title].nil? Assume tokens is a array obtained by splitting a CSV line. now the functions like strip! chomp! et. all return nil if the string was not modified “abc”.strip! # => nil … Read more

Rails 4 Authenticity Token

I was working on a new Rails 4 app (on Ruby 2.0.0-p0) when I ran into some authenticity token problems. While writing a controller that responds to json (using the respond_to class method), I got to the create action I started getting ActionController::InvalidAuthenticityToken exceptions when I tried to create a record using curl. I made … Read more