[Nitro] Problems...

Jeff Wood jeff.darklight at gmail.com
Sun Aug 28 10:33:29 EDT 2005


George Moschovitis wrote:

>Hello,
>
>either define tour classes *before* Og.setup or call og.manage_classes
>after you define them.
>
>-g.
>
George,

I did things the way you asked and got a bit farther ...

Here's my script now...

--SCRIPT--
require 'rubygems'
require 'sqlite3'
require 'og'

class User
    property :name, String
    property :pass, String
    property :age, Fixnum
    has_many :comments, Comment

    def initialize( name, pass, age )
        @name = name
        @pass = pass
        @age = age
    end
end

class Comment
    property :title, String
    property :body, String
    belongs_to User

    def initialize( title, body )
        @title = title
        @body = body
    end
end

db = Og.setup( :store => :sqlite, :name => 'blah' )

a = User.new( "joe", "shhh", 13 )
b = Comment.new( "comment #1", "testing 1 2 3" )
a.comments << b

a.save
b.save

c = User[ 1 ]
puts c.name
puts c.pass
puts c.age
puts "Comments Length : #{ c.comments.length }"
c.comments.each { |curr| puts "#{ curr.title } -- #{ curr.body }" }
--SCRIPT--

And here's the error I get:

================ SQLite3::SQLException =====================
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/errors.rb:94:in 
`check'
            raise ( EXCEPTIONS[result] || SQLite3::Exception ), msg
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/statement.rb:70:in 
`initialize'
          Error.check( result, @db )
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/database.rb:183:in 
`new'
          stmt = @statement_factory.new( self, sql )
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/database.rb:183:in 
`prepare'
          stmt = @statement_factory.new( self, sql )
c:/ruby/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.1.0-mswin32/lib/sqlite3/database.rb:274:in 
`query'
          result = prepare( sql ).execute( *bind_vars )
c:/ruby/lib/ruby/gems/1.8/gems/og-0.22.0/lib/og/store/sqlite.rb:77:in 
`query'
        return @conn.query(sql)
(eval):4:in `og_insert'
    -
c:/ruby/lib/ruby/gems/1.8/gems/og-0.22.0/lib/og/store.rb:121:in `save'
          obj.og_insert(self)
c:/ruby/lib/ruby/gems/1.8/gems/og-0.22.0/lib/og/entity.rb:15:in `save'
          def save(options = nil)
C:\Documents and Settings\jwood\TestRuby\ogtest.rb:37
    b.save
c:\ruby\lib\ruby\site_ruby\1.8/rubygems/custom_require.rb:21:in `require__'
        require__ path
c:\ruby\lib\ruby\site_ruby\1.8/rubygems/custom_require.rb:21:in `require'
        require__ path
 
=============================================
Exception: table ogcomment has no column named user_oid

I guess I'm not as happy with all of the updates as some others might be 
... I think I was playing with version 0.20 or 0.21 ... and all of this 
stuff used to work .. and I didn't used to need to call #save it just 
did it.  It's not that I mind, it's just, well, seems things used to be 
simpler... I guess that's what happens when projects add features ...

Anyways, if you can help, I do appreciate it.

j.




More information about the Nitro-general mailing list