2011-01-16 7 views
1

にモデルを置く...DataMapperの:私は彼らのようなモデルにモデルを置く例を見つけ<a href="http://datamapper.org/docs/associations" rel="nofollow">DataMapper documentation for associations</a>でモデル

1 class Person 
2 
3 class Link 
4 
5  include DataMapper::Resource 
6 
7  storage_names[:default] = 'people_links' 
8 
9  # the person who is following someone 
10  belongs_to :follower, 'Person', :key => true 
11 
12  # the person who is followed by someone 
13  belongs_to :followed, 'Person', :key => true 
14 
15 end 
16 
17 include DataMapper::Resource 
18 
19 property :id, Serial 
20 property :name, String, :required => true 
21 ... 

それはあなたが戻って取得したり、ある結果に影響を持っていますそれはちょうど別の記法または形式ですか?事前に

おかげで、ルーファス

答えて

1

いいえ、それが結果に影響を与えません。

モデルを名前空間に入れると、名前はストレージ名に反映されます。そのため、上記の例では、リンクモデルのstorage_names [:default] = 'people_links'が表示されます。そのモデルはperson namespace内にあり、 "people_links"テーブル名に反映されています。

+0

お返事ありがとうございました! – rufus

関連する問題