[fxruby-users] Using ActiveRecord in FXRuby application

Sarat Kongara saratkongara at gmail.com
Wed May 6 09:02:52 EDT 2009


Hello,
I am a newbie to FXRuby development.

I like the fact that I can write the code in Ruby for cross-platform
GUI development. I am developing a desktop application that needs to
save some information to a database. I am using ActiveRecord for this
purpose.

My code works fine when I don't require fox16 and include Fox. But
once I do that I get a bunch of warnings.

Here is the sample code:

require 'rubygems'
require 'active_record'

require File.expand_path(File.dirname(__FILE__) + "/question_set")

# require 'fox16'
# include Fox

question_set = QuestionSet.new

3.times do
  question = Question.new

  4.times do
    choice = Choice.new
    question.choices << choice
  end

  question_set.questions << question
end

question_set.save!

QuestionSet, Question and Choice inherit from ActiveRecord::Base
QuestionSet has many questions, Question has many choices.

If I uncomment the following two lines

# require 'fox16'
# include Fox

I get these warnings.

/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @choices not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:116:
warning: instance variable @transaction_joinable not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @questions not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @choices not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @choices not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question_set not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question_set not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question_set not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized
/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/associations.rb:100:
warning: instance variable @question not initialized

I tried changing the sequence of require statements but I still get
the same warnings. Has anybody been able to use ActiveRecord in FXRuby
application? Any help/suggestion is really appreciated. Thanks for
your time.

Regards
Sarat


More information about the fxruby-users mailing list