私は現在、既存のデータベースに基づいた新しいアプリに取り組んでおり、データ アクセスに DataMapper を利用しています。ただし、外部キーを扱うときの規則は、データベースが使用するものではありません。
例:
class Invoice
include DataMapper::Resource
storage_names[:default] = 'invoices'
property :id, Serial
# ... more properties ...
has n, :items
end
class Item
include DataMapper::Resource
storage_names[:default] = 'invoiceItems'
property :id, Serial
# ... more properties ...
belongs_to :invoice # this should use 'invoiceId' instead of 'invoice_id'
end
DataMapper が使用する外部キーを、現在使用しようとしている「invoice_id」ではなく「invoiceId」にする方法はありますか (上記のコメントで示されています)。追加することで通常のフィールドでこれを実行できることは知っていますが:field => 'fieldName'、関連付けのような方法は見つかりませんでした。