[Nitro] Idiomatic use for concise Ogging?
George Moschovitis
george.moschovitis at gmail.com
Sat Jun 18 12:19:29 EDT 2005
Hello Aleksi,
> require 'rubygems'
> require_gem 'postgres-pr'
> require_gem 'og'
I suggest you put -rubygems in RUBYOPT and do just a require 'og',
looks cleaner.
> f = Foo.find_by_name("foo").first
You should use Og property metadata:
class Foo
publice :name, String, :unique => true
..
end
now you get a better schmema generated (with a unique constrain) and
find_by_name is clever anough to return just one object instead of the array:
f = Foo.find_by_name('foo')
For a full solution how about:
b = Foo.create unless Foo.find_by_name('foo')
(I don't have access to irb at the moment to verify the above snippet,
but I think this or something similar will work)
--
http://nitro.rubyforge.org
http://www.joy.gr
More information about the Nitro-general
mailing list