Reputation: 28342
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 `<main>': 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?
Upvotes: 0
Views: 5879
Reputation: 677
I got this error
`<class:Employee>': uninitialized constant Employee::Datamapper (NameError)
when compiling. Here is the code
class Employee
include Datamapper::Resource
property :id, Serial
....
The reason for the error was I spelled DataMapper with a lowercase 'm'
Upvotes: 0
Reputation: 369430
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:
Upvotes: 1