Superclass mismatch for class Tempfile

I’ve been facing a problem when generating a model (or controller, …).
I’m
using rails 2.3.8 and ruby 1.8.7.
Has anybody been facing anything like this?

script/generate controller test
/usr/lib/ruby/1.8/tempfile.rb:12: superclass mismatch for class Tempfile
(TypeError)
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in
require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:innew_constants_in’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in
require' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails_generator/commands.rb:4 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:in
new_constants_in' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails_generator.rb:39
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
gem_original_require' from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in
require' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:521:innew_constants_in’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:156:in
require' from /usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/generate.rb:2 from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’
from script/generate:3

Att.
*
Rodrigo F. de Almeida*
Promine Tecnologia da Informação - www.promine.com.br
Project Manager
Sun Certified Java Programmer

Rodrigo F. wrote:

I’ve been facing a problem when generating a model (or controller, …).
I’m
using rails 2.3.8 and ruby 1.8.7.
Has anybody been facing anything like this?

Do you have 2 instances of TempFile (tempfile.rb) or DelegateClass
(delegate.rb) ? Googling around seems to suggest this as a problem.

– raja

OK, but how can I know which class is instantiating TempFile or
DelegateClass? I guess it is related to some plugin, but I`m not sure.

Att.
*
Rodrigo F. de Almeida*
Promine Tecnologia da Informação - www.promine.com.br
Project Manager
Sun Certified Java Programmer

I found the problem. I was defining a new method content_type in the
class
Tempfile.

class Tempfile
def content_type
mime_type = IO.popen(“file --brief --mime #{path}”).gets unless
path.blank?
mime_type
end
end

How can I make this without breaking generators? I’ve already tried the
following one (exactly how it is on the tempfile.rb), but it didn’t
work:

class Tempfile < DelegateClass(File)

end

Should I enclose it by module SomeModuleName … end ?

Thanks in advance.

Att.
*
Rodrigo F. de Almeida*
Promine Tecnologia da Informação - www.promine.com.br
Project Manager
Sun Certified Java Programmer

On Thu, Sep 23, 2010 at 10:58 AM, Rodrigo F. <

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs