From: Stefano Crocco Date: 2010-12-14T17:12:57+09:00 Subject: Re: Conflicting definitions between ActiveRecord and QT On Tuesday 14 December 2010 13:19:29 Emil Macarie wrote: > I am somewhat of a Ruby newbie, so if this question is in the wrong > forum please let me know. > > The specific problem I have is ActiveRecord + QT, but the problem is > generic and I am asking how to solve similar issues as well. > > So I started experimenting with Ruby a bit and I was trying to play > with ActiveRecord. > My first thought was to play with ActiveRecord and understand it > separate from all the Rails infrastructure. > I install ruby 1.9.1, ruby qtbindings, and read up some qt tutorials > and I am ready to rock. > > Even the simplest program throws an error when I try to mix qt and > active record. > > The following lines do not work. > > require 'active_record' > require 'Qt4' > require 'sqlite3' > > class Review < ActiveRecord::Base > end > > I get the error: > /usr/local/rvm/gems/ruby-1.9.2-p0/gems/qtbindings-4.6.3.2/lib/Qt/qtruby4.rb: > 3164:in `constants': wrong number of arguments (1 for 0) (ArgumentError) > from > /usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_suppor > t/core_ext/module/introspection.rb:79:in `local_constants' > > > Basically there is a constants defined for Module in qtruby4.rb as > well as introspection.rb > How can I go about resolving such a conflict. As far as I can see > there are no modules used, just on giant C like global namespace. Is > there any way I can separate qt and active record by namespace ? > > Any suggestions for further research would be very helpful. > > Thanks ! In ruby 1.8, Module#constants takes no arguments and qt-ruby redefines it in the same way. However, in ruby 1.9, Module#constants takes one argument (which is why activesupport calls it with one), but qt-ruby doesn't take this into account when redefining it. I'd say this is a bug in qt-ruby and will report it to the developers. In the meantime, I think you can solve your issue redefining it yourself before requiring activesupport: require 'activesupport' require 'Qt4' class Module alias_method :constants_defined_by_qt, :constants def constants inherit=true constants_defined_by_qt end end I hope this helps Stefano