Sarat Kongara
2009-May-06 13:02 UTC
[fxruby-users] Using ActiveRecord in FXRuby application
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
Lyle Johnson
2009-May-06 14:44 UTC
[fxruby-users] Using ActiveRecord in FXRuby application
On May 6, 2009, at 8:02 AM, Sarat Kongara wrote:> My code works fine when I don''t require fox16 and include Fox. But > once I do that I get a bunch of warnings.<snip> Since they are warning messages, they shouldn''t be causing your program to fail (you just get a lot of noise in the console window). But I have a guess of what might fix it, if you can try something for me locally. For the purpose of this discussion, I''m going to assume that you''ve installed FXRuby via RubyGems, and that it''s installed here: /opt/local/lib/ruby/gems/1.8/gems/fxruby-1.6.19 I want you to make changes to two lines in this file from the FXRuby installation: /opt/local/lib/ruby/gems/1.8/gems/fxruby-1.6.19/lib/fox16/kwargs.rb The first line I want you to change is line 3. It currently reads: $VERBOSE = nil and I want you to change it to: old_verbose = $VERBOSE; $VERBOSE = nil The other line I want you to change is line 2740 (the last line), which currently reads: $VERBOSE = true and I want you to change it to read: $VERBOSE = old_verbose When you''ve changed those two lines, try running your program again and let''s see if that doesn''t clear up all those warnings from ActiveRecord. Hope this helps, Lyle
Sarat Kongara
2009-May-06 15:17 UTC
[fxruby-users] Using ActiveRecord in FXRuby application
Hi Lyle, Thanks for the quick response. I actually followed instructions from your FXRuby book (Create Lean and Mean GUIs with Ruby). I used the command: "sudo port install rb-fxruby" to install fxruby. I found the file kwargs.rb in this folder: /opt/local/lib/ruby/vendor_ruby/1.8/fox16 I made the changes you suggested and I don''t see any warnings now. Earlier I also used to get a warning from rscribd gem code when I am using fox16, now that is gone too. Is it safe to ignore these warnings and keep the changes in the file kwargs.rb permanently? Thanks again. Regards Sarat On 5/6/09, Lyle Johnson <lyle at lylejohnson.name> wrote:> > On May 6, 2009, at 8:02 AM, Sarat Kongara wrote: > >> My code works fine when I don''t require fox16 and include Fox. But >> once I do that I get a bunch of warnings. > > <snip> > > Since they are warning messages, they shouldn''t be causing your > program to fail (you just get a lot of noise in the console window). > But I have a guess of what might fix it, if you can try something for > me locally. > > For the purpose of this discussion, I''m going to assume that you''ve > installed FXRuby via RubyGems, and that it''s installed here: > > /opt/local/lib/ruby/gems/1.8/gems/fxruby-1.6.19 > > I want you to make changes to two lines in this file from the FXRuby > installation: > > /opt/local/lib/ruby/gems/1.8/gems/fxruby-1.6.19/lib/fox16/kwargs.rb > > The first line I want you to change is line 3. It currently reads: > > $VERBOSE = nil > > and I want you to change it to: > > old_verbose = $VERBOSE; $VERBOSE = nil > > The other line I want you to change is line 2740 (the last line), > which currently reads: > > $VERBOSE = true > > and I want you to change it to read: > > $VERBOSE = old_verbose > > When you''ve changed those two lines, try running your program again > and let''s see if that doesn''t clear up all those warnings from > ActiveRecord. > > Hope this helps, > > Lyle > > _______________________________________________ > fxruby-users mailing list > fxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/fxruby-users >
Lyle Johnson
2009-May-06 16:08 UTC
[fxruby-users] Using ActiveRecord in FXRuby application
On May 6, 2009, at 10:17 AM, Sarat Kongara wrote:> I made the changes you suggested and I don''t see any warnings now.Excellent.> Earlier I also used to get a warning from rscribd gem code when I am > using fox16, now that is gone too.OK.> Is it safe to ignore these warnings and keep the changes in the file > kwargs.rb permanently? Thanks again.Yes to both questions. I will implement this change in the next release of FXRuby, so when you upgrade to FXRuby 1.6.20 you won''t need to re-patch your kwargs.rb file. Thanks for your help, Lyle