tags:

views:

425

answers:

1

Hello, I have two ruby files. The first is

require 'www/poster'

poster = Poster.new()

The second ('www/poster.rb') is

require ...

class Poster ... end

The problem is, when I run the first file, I get an error: in `': uninitialized constant Poster (NameError) But if I replace the original code with just

require ...
class Poster

end

__END__
class Poster #original class here

it's ok. The code worked fine in Ruby 1.8.6, problems started after upgrading to 1.9.1p129 (2009-05-12 revision 23412) [i386-mswin32]. Is there any workaround? TIA

+1  A: 

There is absolutely nothing whatsoever in your code that would cause it to behave differently in Ruby 1.9 than in Ruby 1.8. And indeed, when I copy & paste the code you posted into two files, they work exactly like the are supposed to, in all of the following configurations:

  • MRI Ruby 1.8.6 (2009-03-31 patchlevel 368) [i386-mingw32]
  • YARV Ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]
  • JRuby 1.4.0dev (ruby 1.8.7p174) (2009-08-24 6586) (Java HotSpot(TM) Client VM 1.6.0_14-ea) [x86-java]
  • JRuby 1.4.0dev (ruby 1.9.1p0) (2009-08-24 6586) (Java HotSpot(TM) Client VM 1.6.0_14-ea) [x86-java]
Jörg W Mittag
well, in the erroneous '...' means some skipped code, but thanks for the efforts, in my case there was some unicode connected error that ruby interpreter didn't wan't to report for some reason :/
roddik