[Nitro] More Create Schema Trouble

Dan Yoder dan at zeraweb.com
Tue Mar 22 14:22:50 EST 2005


Hi George,

I have a simple app that just has one model and a simple controller  
that uses the scaffold. When I run the app, the first thing that  
happens is the usual problem with the creation of the database. So I do  
that by hand, and then I get a create table error:

  INFO: Connecting to database 'cruiser' using the 'mysql' adapter.
DEBUG: Og auto manages the following classes:
DEBUG: [Story]
/usr/local/lib/ruby/1.8/mysql.rb:453:in `read': You have an error in  
your SQL syntax.  Check the manual that corresponds to your MySQL  
server version for the right syntax to use near ' oid integer  
AUTO_INCREMENT PRIMARY KEY)' at line 1 (Mysql::Error)
         from /usr/local/lib/ruby/1.8/mysql.rb:345:in `read_query_result'
         from /usr/local/lib/ruby/1.8/mysql.rb:160:in `real_query'
         from /usr/local/lib/ruby/1.8/mysql.rb:275:in `query'
         from  
/usr/local/lib/ruby/gems/1.8/gems/og-0.13.0/lib/og/adapters/mysql.rb: 
178:in `create_table'
         from  
/usr/local/lib/ruby/gems/1.8/gems/og-0.13.0/lib/og/database.rb:214:in  
`convert'
         from  
/usr/local/lib/ruby/gems/1.8/gems/og-0.13.0/lib/og/database.rb:159:in  
`manage'
         from  
/usr/local/lib/ruby/gems/1.8/gems/og-0.13.0/lib/og/database.rb:169:in  
`manage_classes'
         from  
/usr/local/lib/ruby/gems/1.8/gems/og-0.13.0/lib/og/database.rb:168:in  
`each'
         from  
/usr/local/lib/ruby/gems/1.8/gems/og-0.13.0/lib/og/database.rb:168:in  
`manage_classes'
         from  
/usr/local/lib/ruby/gems/1.8/gems/og-0.13.0/lib/og/database.rb:93:in  
`initialize'
         from run.rb:14:in `new'
         from run.rb:14

My source follows:

******************************
run.rb
******************************

require 'nitro'
require 'og'
require 'controllers/story_controller'
include N

Og.create_schema = true

runner = Runner.new.setup

db = Og::Database.new(
	:address => 'localhost',
	:adapter => 'mysql',
	:database => 'cruiser',
	:user => 'root',
	:password => '',
	:connection_count => 3
)

conf = Conf.new(
	:name => 'Cruiser Demo',
	:host => '127.0.0.1',
	:port => 3000,
	:dispatcher => Dispatcher.new(StoryController)
)

runner.run(conf)

******************************
StoryController.rb
******************************

require 'nitro/controller'
require 'models/story'

class StoryController < N::Controller
   scaffold Story, :name => 'story', :index => true
end

******************************
Story.rb
******************************

include N
class Story
   prop_accessor :title, String
   prop_accessor :body, String
   prop_accessor :created, Date
   prop_accessor :publish, Date
   prop_accessor :expire, Data
   validate_value :title, :msg => 'Please provide a title'
   validate_value :body, :msg => 'Please provide an article body'
end




More information about the Nitro-general mailing list