public
Description: Slides and code for RailsConf session on building a composite model and exploring ActiveRecord
Homepage: http://www.technomage.com
Clone URL: git://github.com/technomage/railsconf-2008-composite.git
Update slides and files
Michael Latta (author)
Sun May 11 16:24:49 -0700 2008
commit  19c31f986385500a3d0c79b7a67ff7cf26bd69b5
tree    455df4446a0a80f3c83da7ed2b01615ff3f7b3e0
parent  6d3b709cb69352ce3d5393530b5c1e3c5f1ed7d6
...
3
4
5
6
 
7
8
9
...
13
14
15
16
17
18
19
20
...
65
66
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
69
70
...
79
80
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
83
84
...
86
87
88
89
 
90
91
92
...
165
166
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
169
170
...
211
212
213
 
 
 
214
215
216
...
220
221
222
 
223
224
225
226
227
228
229
 
230
231
...
3
4
5
 
6
7
8
9
...
13
14
15
 
 
16
17
18
...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
...
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
...
112
113
114
 
115
116
117
118
...
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
...
265
266
267
268
269
270
271
272
273
...
277
278
279
280
281
282
283
284
285
286
 
287
288
289
0
@@ -3,7 +3,7 @@
0
 <plist version="1.0">
0
 <dict>
0
   <key>currentDocument</key>
0
- <string>composite/app/controllers/virtual_item_controller.rb</string>
0
+ <string>composite/app/models/virtual_item.rb</string>
0
   <key>documents</key>
0
   <array>
0
     <dict>
0
@@ -13,8 +13,6 @@
0
       <string>composite</string>
0
       <key>regexFolderFilter</key>
0
       <string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
0
- <key>selected</key>
0
- <true/>
0
       <key>sourceDirectory</key>
0
       <string>composite</string>
0
     </dict>
0
@@ -65,6 +63,20 @@
0
       <key>firstVisibleLine</key>
0
       <integer>0</integer>
0
     </dict>
0
+ <key>composite/app/models/group.rb</key>
0
+ <dict>
0
+ <key>caret</key>
0
+ <dict>
0
+ <key>column</key>
0
+ <integer>0</integer>
0
+ <key>line</key>
0
+ <integer>0</integer>
0
+ </dict>
0
+ <key>firstVisibleColumn</key>
0
+ <integer>0</integer>
0
+ <key>firstVisibleLine</key>
0
+ <integer>0</integer>
0
+ </dict>
0
     <key>composite/app/models/item.rb</key>
0
     <dict>
0
       <key>caret</key>
0
@@ -79,6 +91,20 @@
0
       <key>firstVisibleLine</key>
0
       <integer>0</integer>
0
     </dict>
0
+ <key>composite/app/models/place.rb</key>
0
+ <dict>
0
+ <key>caret</key>
0
+ <dict>
0
+ <key>column</key>
0
+ <integer>0</integer>
0
+ <key>line</key>
0
+ <integer>0</integer>
0
+ </dict>
0
+ <key>firstVisibleColumn</key>
0
+ <integer>0</integer>
0
+ <key>firstVisibleLine</key>
0
+ <integer>0</integer>
0
+ </dict>
0
     <key>composite/app/models/virtual_item.rb</key>
0
     <dict>
0
       <key>caret</key>
0
@@ -86,7 +112,7 @@
0
         <key>column</key>
0
         <integer>3</integer>
0
         <key>line</key>
0
- <integer>2</integer>
0
+ <integer>15</integer>
0
       </dict>
0
       <key>firstVisibleColumn</key>
0
       <integer>0</integer>
0
@@ -165,6 +191,34 @@
0
       <key>firstVisibleLine</key>
0
       <integer>0</integer>
0
     </dict>
0
+ <key>composite/db/migrate/002_create_groups.rb</key>
0
+ <dict>
0
+ <key>caret</key>
0
+ <dict>
0
+ <key>column</key>
0
+ <integer>0</integer>
0
+ <key>line</key>
0
+ <integer>0</integer>
0
+ </dict>
0
+ <key>firstVisibleColumn</key>
0
+ <integer>0</integer>
0
+ <key>firstVisibleLine</key>
0
+ <integer>0</integer>
0
+ </dict>
0
+ <key>composite/db/migrate/003_create_places.rb</key>
0
+ <dict>
0
+ <key>caret</key>
0
+ <dict>
0
+ <key>column</key>
0
+ <integer>20</integer>
0
+ <key>line</key>
0
+ <integer>3</integer>
0
+ </dict>
0
+ <key>firstVisibleColumn</key>
0
+ <integer>0</integer>
0
+ <key>firstVisibleLine</key>
0
+ <integer>0</integer>
0
+ </dict>
0
     <key>composite/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb</key>
0
     <dict>
0
       <key>caret</key>
0
@@ -211,6 +265,9 @@
0
   <key>openDocuments</key>
0
   <array>
0
     <string>composite/app/controllers/virtual_item_controller.rb</string>
0
+ <string>composite/app/models/group.rb</string>
0
+ <string>composite/db/migrate/003_create_places.rb</string>
0
+ <string>composite/db/migrate/002_create_groups.rb</string>
0
     <string>composite/app/models/virtual_item.rb</string>
0
     <string>composite/app/controllers/item_controller.rb</string>
0
     <string>composite/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb</string>
0
@@ -220,12 +277,13 @@
0
     <string>composite/app/controllers/application.rb</string>
0
     <string>composite/app/views/layouts/technomage.html.erb</string>
0
     <string>composite/app/models/item.rb</string>
0
+ <string>composite/app/models/place.rb</string>
0
     <string>composite/db/migrate/001_create_items.rb</string>
0
     <string>composite/config/routes.rb</string>
0
   </array>
0
   <key>showFileHierarchyDrawer</key>
0
   <true/>
0
   <key>windowFrame</key>
0
- <string>{{307, 488}, {1592, 1000}}</string>
0
+ <string>{{1451, 380}, {1044, 1157}}</string>
0
 </dict>
0
 </plist>
...
1
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
4
...
1
 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
0
@@ -1,3 +1,16 @@
0
 class VirtualItem
0
-
0
+ def self.columns
0
+ unless @columns
0
+ @columns = []
0
+ Item.columns.each do | col |
0
+ column = ActiveRecord::ConnectionAdapters::Column.new(col.name, '', col.type)
0
+ end
0
+ end
0
+ end
0
+
0
+ # Return the association reflection objects. Currently this is empty as the
0
+ # virtual item does not need to support associations
0
+ def self.reflect_on_all_associations(macro = nil)
0
+ []
0
+ end
0
 end
0
\ No newline at end of file
...
1
2
3
4
 
5
6
7
...
1
2
3
 
4
5
6
7
0
@@ -1,7 +1,7 @@
0
 class CreatePlaces < ActiveRecord::Migration
0
   def self.up
0
     create_table :places do |t|
0
-
0
+ t.string :name
0
       t.timestamps
0
     end
0
   end

Comments

    No one has commented yet.