I am getting this strange error for a when I am checking a class variable in ruby
undefined method `blank?' for "123":String (NoMethodError)
all I am doing is Employee.set_id.blank?
Any ideas why this could be happening?
Thanks.
The blank? method is defined for every Ruby object that is descendant of the Object class in activesupport gem (https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/blank.rb).
This gem is part of Rails framework. However, if you still want to use this utility of activesupport in your non-Rails Ruby project, you can require it in your source files with the sentence:
require 'active_support/core_ext'
Make sure you have installed activesupport gem in your system.
Use Employee.set_id.nil? || Employee.set_id.strip.empty? instead.
String#blank? is defined in ActiveSupport
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With