DataMapper: Putting a model into a model
In t开发者_C百科he DataMapper documentation for associations I found an example where they put a model into a model like...
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 ...
Does it have any influence on the result you get back or is it just another notation or format?
Thanks in advance, rufus
No, it doesn't have any influence on the result.
If you put your models in a namespace it will reflect in storage names though. That's why in the example above you see "storage_names[:default] = 'people_links'" in Link model, because that model is inside Person namespace, which is reflected in "people_links" table name.
精彩评论