Conflicting definitions between ActiveRecord and QT

E

Emil Macarie

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_support/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 !
 
S

Stefano Crocco

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
 
E

Emil Macarie

Stefano Crocco wrote in post #968233:
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

Thank you for your help. I will give that a shot as soon as I get back
to my Ruby environment.

I'll also try to see if I can get something working where constants with
no arguments and constants with an argument point to different
functions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top