Take the 2-minute tour ×

I'm trying to use activeSupport's blank method in a script and getting the error "undefined method 'blank?' for "blah":String (NoMethodError)". Ruby doesn't have an issue with the require statement but I can't use the library.

require "rubygems"
require "active_support"

if "blah".blank?
  puts "blank!"
share|improve this question

2 Answers 2

Which version of ActiveSupport are you using? In current versions, it does no longer load every single feature into the namespace by default. Instead, you can pick and choose exactly which features you need. In your case:

require 'rubygems'
require 'active_support/core_ext/object/blank'

puts 'blank!' if 'blah'.blank?

If you want everything, use

require 'active_support/all'

Actually, in modern versions of Ruby, you can get rid of the require 'rubygems' as well. And even in older versions, you shouldn't put that there, since it forces every user of your code to use RubyGems and makes it impossible to use in environments where RubyGems is not available.

share|improve this answer
That did indeed fix it! The gem I was trying to get to work did not specify a specific version of activesupport. –  user518175 Nov 27 '10 at 16:32

Hmm, I just tried this and it worked fine (didn't print anything).

share|improve this answer

Your Answer


