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.
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:inlocal_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.
On Tuesday 14 December 2010 13:19:29 Emil M. wrote:
I install ruby 1.9.1, ruby qtbindings, and read up some qt tutorials
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
On Tuesday 14 December 2010 13:19:29 Emil M. wrote:
I install ruby 1.9.1, ruby qtbindings, and read up some qt tutorials
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
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.