$ script/console
Loading development environment (Rails 1.2.5)
INFO: Og uses the Sqlite store.
INFO: Created table ogtodolistitem.
INFO: Created table ogtodolist.
INFO: Created table ogtag.
>>
All Og-managed tables currently start with og and are simply the downcased, alphanumeric
versions of the class names. The primary key defaults to oid, not id. The
ogtag table was created because the optional tagging module was loaded; it currently
creates a table whether it is in use or not.
Now we can create a to-do list and some items:
>> og = TodoList.create_with :name => 'Og', :position => 1
=> #
>> item1 = TodoListItem.create_with \
:name => "Make Og work with ActiveSupport's Dependencies",
:position => 1, :todo_list => og
=> #@name="Make Og work with ActiveSupport's Dependencies", @position=1,
@oid=1>
>> item2 = TodoListItem.create_with \
:name => "Autoload Orderable so that Ruby can find it",
:position => 2, :todo_list => og
=> #@name="Autoload Orderable so that Ruby can find it", @position=2,
@oid=2>
Replacing Rails Components | 281
Og has finder methods reminiscent of ActiveRecord??™s, but with slightly different
syntax:
>> TodoList[1]
=> #
>> TodoList.
Pages:
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427