[fxruby-users] Accessing SQLite database in FXRuby application
jkinsella at ancillaryservices.com
Sat Feb 27 09:34:04 EST 2010
Try changing the following block:
TestApp.new do |app|
app = TestApp.new
I think (but I could be mistaken) when you pass a block to FXApp.new it's
more like this:
If this is the case, then @db would never get initialized, since the
overloaded initialized method would never be called.
On Fri, Feb 26, 2010 at 8:39 PM, Will Parsons <wbparsons at cshore.com> wrote:
> I'm trying to develop an application that accesses an SQLite database and
> am running into problems related to using getApp (probably because of some
> simple misunderstanding of how FXRuby works on my part). The following is
> a stripped-down version of my (non-functioning) program:
> #!/usr/bin/env ruby
> require 'fox16'
> require 'sqlite3'
> include Fox
> class TestApp < FXApp
> def initialize
> super('Test', 'Test')
> @db = SQLite3::Database.new('test.db3')
> @db || raise("can't connect to database")
> def db
> class TestTable < FXTable
> def initialize(p)
> super(p, :opts => LAYOUT_FILL|PACK_UNIFORM_WIDTH|TABLE_COL_SIZABLE)
> db = getApp.db
> db || raise("can't access DB") # <---- this condition is raised
> setTableSize(3, 3)
> # fill table with data from database...
> class TopLevelWindow < FXMainWindow
> def initialize(app)
> super(app, 'Test', :width => 400, :height => 100)
> def create
> TestApp.new do |app|
> When run, the condition "can't access DB" is raised. This is probably
> but I can't seem to figure out what I'm doing wrong.
> fxruby-users mailing list
> fxruby-users at rubyforge.org
If you are not the intended recipient, you are hereby notified
that any dissemination, distribution, copying or other use of
this communication is strictly prohibited. If you have
received this communication in error, please notify us
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the fxruby-users