Pages

Thursday, October 25, 2012

invalid multibyte escape (ArgumentError)

Hi! After updating from Ruby 1.8.7 to Ruby 1.9.3, I've got errors with the gem validate_as_email at line
pattern = /\A#{addr_spec}\z/
Error Message:
D:/Ruby193/lib/ruby/gems/1.9.1/gems/validates_as_email-0.5.1/lib/validates_as_email.rb:28:in `': invalid multibyte escape (ArgumentError)
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/validates_as_email-0.5.1/lib/validates_as_email.rb:13:in `'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `require'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `each'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/runtime.rb:66:in `block in require'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `each'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler/runtime.rb:55:in `require'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.2.1/lib/bundler.rb:128:in `require'
 from H:/BRPB2B/config/application.rb:7:in `'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in '
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
 from D:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `'
 from H:/BRPB2B/script/rails:6:in `require'
 from H:/BRPB2B/script/rails:6:in `'
 from -e:1:in `load'
 from -e:1:in `
'
The problem is that using /my_regex/ is not valid anymore. You must use instead.
pattern =  Regexp.new "\A#{addr_spec}\z", nil, 'n'

Wednesday, October 24, 2012

PHPExcel - Image in a cell

$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName('test_img');
$objDrawing->setDescription('test_img');
$objDrawing->setPath('assets/images/success.png');
$objDrawing->setCoordinates('A4');
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());

Tuesday, October 16, 2012

Remove all Ruby Gems in one command


  • Open the command manager
  • Type powershell
  • Type gem list | %{$_.split(' ')[0]} | %{gem uninstall -Iax $_ }