Resending
With a fresh darcs get ( 30 minutes ago ) and this test program:
#!/usr/bin/env ruby
require ‘ubygems’
require ‘sqlite3’
require ‘nitro_and_og’
include Nitro
require ‘nitro/part/admin’
Og model
class Book
attr_accessor :title, String
attr_accessor :author, String
end
Controller
class Foo
def index
render_text “Foo”
end
end
Og.create_schema = true
Og.use_uuid_primary_keys = true
Og.start( :name => “library”, :adapter => :sqlite, :evolve_schema =>
:full )
app=Application.new
app.dispatcher.root = Foo
app.start
Saving a ‘Book’ produces this exception:
ERROR: Error while handling OgAdminController#save()
ERROR: undefined method `[]’ for nil:NilClass
/Users/rmela/nitro2/repo.nitroproject.org/script/lib/…/…/raw/lib/raw/context/request.rb:304:in
`[]’
/Users/rmela/nitro2/repo.nitroproject.org/script/lib/…/…/nitro/lib/nitro/part/admin/og/controller.rb:93:in
`save’
Line 93 throws the exception:
92 def save
93 klass = name_to_class(request['object_class_name'].to_s)
94
95 if oid = request['oid']
96 obj = klass[oid.to_s]
97 obj.assign(request, :assign_relations => true,
:force_boolean => true)
98 else
99 obj = klass.new
100 obj.assign(request, :assign_relations => true)
101 end
I modified that slightly to produce some output:
92 def save
93 if request.nil?
94 puts "OGADMIN request returns 'nil'"
95 else
96 puts "OGADMIN request() returns a #{request.class.name}"
97 puts "OGADMIN request.params returns #{request.params ||
‘nil’}"
98 puts “OGADMIN request[‘oid’] returns #{request[‘oid’]}”
99 end
which produced this exception:
ERROR: undefined method []' for nil:NilClass /Users/rmela/nitro/repo.nitroproject.org/script/lib/../../raw/lib/raw/context/request.rb:304:in
[]’
/Users/rmela/nitro/repo.nitroproject.org/script/lib/…/…/nitro/lib/nitro/part/admin/og/controller.rb:98:in
`save’
And this output:
OGADMIN request() returns a Raw::Context
OGADMIN request.params returns nil