hobo 1.3.0.pre22 → 1.3.0.pre23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0.pre22
1
+ 1.3.0.pre23
@@ -285,18 +285,14 @@ Gives the N most recent items:
285
285
 
286
286
  ## include
287
287
 
288
- DEPRECATED: Automatic scope :include has been deprecated: use :including instead.
288
+ DEPRECATED: Automatic scope :include has been deprecated: use :includes instead.
289
289
 
290
- ## including
290
+ ## includes
291
291
 
292
- Adding the including function to your query chain has the same effect as
293
- the `:include` option to the `find` method.
294
-
295
- >> Person.search("B", :name).including(:friends).*.name # test LH#839
292
+ >> Person.search("B", :name).includes(:friends).*.name # test LH#839
296
293
  => ["Bryan", "Bethany"]
297
- .hidden
298
294
 
299
- >> Person.including(:friends).*.name
295
+ >> Person.includes(:friends).*.name
300
296
  => ["Bryan", "Bethany"]
301
297
 
302
298
  ## search
@@ -58,10 +58,9 @@ module Hobo
58
58
 
59
59
  def hobo_ajax_response(*args)
60
60
  results = args.extract_options!
61
- page_path = params[:page_path]
62
61
  r = params[:render]
63
62
  if r
64
- ajax_update_response(page_path, r.values, results)
63
+ ajax_update_response(r.values, results)
65
64
  true
66
65
  else
67
66
  false
@@ -69,15 +68,13 @@ module Hobo
69
68
  end
70
69
 
71
70
 
72
- def ajax_update_response(page_path, render_specs, results={})
73
- if page_path
74
- controller, action = controller_action_from_page_path(page_path)
75
- identifier = view_context.view_paths.find( action,
76
- controller,
77
- false,
78
- view_context.lookup_context.instance_variable_get('@details')).identifier
79
- renderer = Dryml.page_renderer(view_context, identifier, [], controller)
80
- end
71
+ def ajax_update_response(render_specs, results={})
72
+ controller, action = controller_action_from_page_path
73
+ identifier = view_context.view_paths.find( action,
74
+ controller,
75
+ false,
76
+ view_context.lookup_context.instance_variable_get('@details')).identifier
77
+ renderer = Dryml.page_renderer(view_context, identifier, [], controller)
81
78
 
82
79
  render :update do |page|
83
80
  page << "var _update = typeof Hobo == 'undefined' ? Element.update : Hobo.updateElement;"
@@ -23,12 +23,12 @@ module Hobo
23
23
  end
24
24
 
25
25
  ActiveSupport.on_load(:active_record) do
26
- require 'hobo/extensions/active_record/association_collection'
27
- require 'hobo/extensions/active_record/association_proxy'
28
- require 'hobo/extensions/active_record/association_reflection'
26
+ require 'hobo/extensions/active_record/associations/collection'
27
+ require 'hobo/extensions/active_record/associations/proxy'
28
+ require 'hobo/extensions/active_record/associations/reflection'
29
29
  require 'hobo/extensions/active_record/hobo_methods'
30
30
  require 'hobo/extensions/active_record/permissions'
31
- require 'hobo/extensions/active_record/scopes'
31
+ require 'hobo/extensions/active_record/associations/scope'
32
32
  require 'hobo/extensions/active_record/relation_with_origin'
33
33
  require 'hobo/extensions/active_model/name'
34
34
  require 'hobo/extensions/active_model/translation'
@@ -2,17 +2,16 @@ module ActiveRecord
2
2
  module Associations
3
3
  class AssociationProxy #:nodoc:
4
4
 
5
- def origin
6
- proxy_owner
7
- end
5
+ def origin
6
+ proxy_owner
7
+ end
8
8
 
9
- def origin_attribute
10
- proxy_reflection.name
11
- end
9
+ def origin_attribute
10
+ proxy_reflection.name
11
+ end
12
12
 
13
13
  private
14
14
 
15
-
16
15
  def raise_on_type_mismatch(record)
17
16
  # Don't complain if the interface type of a polymorphic association doesn't exist
18
17
  klass = @reflection.klass rescue nil
@@ -0,0 +1,23 @@
1
+ module ActiveRecord
2
+ module Reflection
3
+ class AssociationReflection
4
+
5
+ alias_method :association_name, :name
6
+
7
+ def klass_with_create_polymorphic_class
8
+ if options[:polymorphic]
9
+ begin
10
+ klass_without_create_polymorphic_class
11
+ rescue NameError => e
12
+ Object.class_eval "class #{e.missing_name} < ActiveRecord::Base; set_table_name '#{active_record.name.tableize}'; end"
13
+ e.missing_name.constantize
14
+ end
15
+ else
16
+ klass_without_create_polymorphic_class
17
+ end
18
+ end
19
+ alias_method_chain :klass, :create_polymorphic_class
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,35 @@
1
+ # Add support for :scope => :my_scope to associations
2
+
3
+ module ActiveRecord
4
+ module Associations
5
+ module ThroughAssociationScope
6
+
7
+ def construct_scope_with_scope
8
+ s = construct_scope_without_scope
9
+ s[:find][:scope] = @reflection.options[:scope]
10
+ s
11
+ end
12
+ alias_method_chain :construct_scope, :scope
13
+
14
+ end
15
+ end
16
+
17
+ module SpawnMethods
18
+
19
+ def apply_finder_options_with_scope(options)
20
+ scopes = []
21
+ Array.wrap(options.delete(:scope)).each do |s|
22
+ if s.is_a?(Hash)
23
+ s.each_pair{|k,v| scopes << [k,v] }
24
+ else
25
+ scopes << [s]
26
+ end
27
+ end
28
+ relation = apply_finder_options_without_scope(options)
29
+ return relation if scopes.empty?
30
+ scopes.inject(relation) {|r, s| r.send *s }
31
+ end
32
+ alias_method_chain :apply_finder_options, :scope
33
+
34
+ end
35
+ end
@@ -1,4 +1,7 @@
1
1
  # Add support for type metadata to arrays
2
+
3
+ require 'will_paginate/array'
4
+
2
5
  class Array
3
6
 
4
7
  attr_accessor :member_class, :origin, :origin_attribute
@@ -12,4 +15,13 @@ class Array
12
15
  origin and origin_id = origin.try.typed_id and "#{origin_id}:#{origin_attribute}"
13
16
  end
14
17
 
18
+ def paginate_with_hobo_metadata(*args, &block)
19
+ collection = paginate_without_hobo_metadata(*args, &block)
20
+ collection.member_class = member_class
21
+ collection.origin = try.proxy_owner
22
+ collection.origin_attribute = try.proxy_reflection._?.name
23
+ collection
24
+ end
25
+ alias_method_chain :paginate, :hobo_metadata
26
+
15
27
  end
@@ -61,7 +61,7 @@ module Hobo
61
61
  WillPaginate::Finders::Base.class_eval do
62
62
  def paginate_with_hobo_metadata(*args, &block)
63
63
  collection = paginate_without_hobo_metadata(*args, &block)
64
- collection.member_class = self
64
+ collection.member_class = self.is_a?(ActiveRecord::Relation) ? member_class : self
65
65
  collection.origin = try.proxy_owner
66
66
  collection.origin_attribute = try.proxy_reflection._?.name
67
67
  collection
@@ -212,7 +212,7 @@ module Hobo
212
212
  end
213
213
 
214
214
  def clear_key
215
- record.write_attribute key_timestamp_field, nil
215
+ record.send :write_attribute, key_timestamp_field, nil
216
216
  end
217
217
 
218
218
  def invariants_satisfied?
@@ -31,11 +31,11 @@ module Hobo
31
31
  def create_scope(check_only=false)
32
32
  matched_scope = true
33
33
 
34
-
34
+ case
35
35
  # --- Association Queries --- #
36
36
 
37
37
  # with_players(player1, player2)
38
- if name =~ /^with_(.*)/ && (refl = reflection($1))
38
+ when name =~ /^with_(.*)/ && (refl = reflection($1))
39
39
  return true if check_only
40
40
 
41
41
  def_scope do |*records|
@@ -49,7 +49,7 @@ module Hobo
49
49
  end
50
50
 
51
51
  # with_player(a_player)
52
- elsif name =~ /^with_(.*)/ && (refl = reflection($1.pluralize))
52
+ when name =~ /^with_(.*)/ && (refl = reflection($1.pluralize))
53
53
  return true if check_only
54
54
 
55
55
  exists_sql = exists_sql_condition(refl)
@@ -59,7 +59,7 @@ module Hobo
59
59
  end
60
60
 
61
61
  # any_of_players(player1, player2)
62
- elsif name =~ /^any_of_(.*)/ && (refl = reflection($1))
62
+ when name =~ /^any_of_(.*)/ && (refl = reflection($1))
63
63
  return true if check_only
64
64
 
65
65
  def_scope do |*records|
@@ -73,7 +73,7 @@ module Hobo
73
73
  end
74
74
 
75
75
  # without_players(player1, player2)
76
- elsif name =~ /^without_(.*)/ && (refl = reflection($1))
76
+ when name =~ /^without_(.*)/ && (refl = reflection($1))
77
77
  return true if check_only
78
78
 
79
79
  def_scope do |*records|
@@ -87,7 +87,7 @@ module Hobo
87
87
  end
88
88
 
89
89
  # without_player(a_player)
90
- elsif name =~ /^without_(.*)/ && (refl = reflection($1.pluralize))
90
+ when name =~ /^without_(.*)/ && (refl = reflection($1.pluralize))
91
91
  return true if check_only
92
92
 
93
93
  exists_sql = exists_sql_condition(refl)
@@ -97,7 +97,7 @@ module Hobo
97
97
  end
98
98
 
99
99
  # team_is(a_team)
100
- elsif name =~ /^(.*)_is$/ && (refl = reflection($1)) && refl.macro.in?([:has_one, :belongs_to])
100
+ when name =~ /^(.*)_is$/ && (refl = reflection($1)) && refl.macro.in?([:has_one, :belongs_to])
101
101
  return true if check_only
102
102
 
103
103
  if refl.options[:polymorphic]
@@ -113,7 +113,7 @@ module Hobo
113
113
  end
114
114
 
115
115
  # team_is_not(a_team)
116
- elsif name =~ /^(.*)_is_not$/ && (refl = reflection($1)) && refl.macro.in?([:has_one, :belongs_to])
116
+ when name =~ /^(.*)_is_not$/ && (refl = reflection($1)) && refl.macro.in?([:has_one, :belongs_to])
117
117
  return true if check_only
118
118
 
119
119
  if refl.options[:polymorphic]
@@ -132,7 +132,7 @@ module Hobo
132
132
  # --- Column Queries --- #
133
133
 
134
134
  # name_is(str)
135
- elsif name =~ /^(.*)_is$/ && (col = column($1))
135
+ when name =~ /^(.*)_is$/ && (col = column($1))
136
136
  return true if check_only
137
137
 
138
138
  def_scope do |str|
@@ -140,7 +140,7 @@ module Hobo
140
140
  end
141
141
 
142
142
  # name_is_not(str)
143
- elsif name =~ /^(.*)_is_not$/ && (col = column($1))
143
+ when name =~ /^(.*)_is_not$/ && (col = column($1))
144
144
  return true if check_only
145
145
 
146
146
  def_scope do |str|
@@ -148,7 +148,7 @@ module Hobo
148
148
  end
149
149
 
150
150
  # name_contains(str)
151
- elsif name =~ /^(.*)_contains$/ && (col = column($1))
151
+ when name =~ /^(.*)_contains$/ && (col = column($1))
152
152
  return true if check_only
153
153
 
154
154
  def_scope do |str|
@@ -156,7 +156,7 @@ module Hobo
156
156
  end
157
157
 
158
158
  # name_does_not_contain
159
- elsif name =~ /^(.*)_does_not_contain$/ && (col = column($1))
159
+ when name =~ /^(.*)_does_not_contain$/ && (col = column($1))
160
160
  return true if check_only
161
161
 
162
162
  def_scope do |str|
@@ -164,7 +164,7 @@ module Hobo
164
164
  end
165
165
 
166
166
  # name_starts(str)
167
- elsif name =~ /^(.*)_starts$/ && (col = column($1))
167
+ when name =~ /^(.*)_starts$/ && (col = column($1))
168
168
  return true if check_only
169
169
 
170
170
  def_scope do |str|
@@ -172,7 +172,7 @@ module Hobo
172
172
  end
173
173
 
174
174
  # name_does_not_start
175
- elsif name =~ /^(.*)_does_not_start$/ && (col = column($1))
175
+ when name =~ /^(.*)_does_not_start$/ && (col = column($1))
176
176
  return true if check_only
177
177
 
178
178
  def_scope do |str|
@@ -180,7 +180,7 @@ module Hobo
180
180
  end
181
181
 
182
182
  # name_ends(str)
183
- elsif name =~ /^(.*)_ends$/ && (col = column($1))
183
+ when name =~ /^(.*)_ends$/ && (col = column($1))
184
184
  return true if check_only
185
185
 
186
186
  def_scope do |str|
@@ -188,7 +188,7 @@ module Hobo
188
188
  end
189
189
 
190
190
  # name_does_not_end(str)
191
- elsif name =~ /^(.*)_does_not_end$/ && (col = column($1))
191
+ when name =~ /^(.*)_does_not_end$/ && (col = column($1))
192
192
  return true if check_only
193
193
 
194
194
  def_scope do |str|
@@ -196,7 +196,7 @@ module Hobo
196
196
  end
197
197
 
198
198
  # published (a boolean column)
199
- elsif (col = column(name)) && (col.type == :boolean)
199
+ when (col = column(name)) && (col.type == :boolean)
200
200
  return true if check_only
201
201
 
202
202
  def_scope do
@@ -204,7 +204,7 @@ module Hobo
204
204
  end
205
205
 
206
206
  # not_published
207
- elsif name =~ /^not_(.*)$/ && (col = column($1)) && (col.type == :boolean)
207
+ when name =~ /^not_(.*)$/ && (col = column($1)) && (col.type == :boolean)
208
208
  return true if check_only
209
209
 
210
210
  def_scope do
@@ -212,7 +212,7 @@ module Hobo
212
212
  end
213
213
 
214
214
  # published_before(time)
215
- elsif name =~ /^(.*)_before$/ && (col = column("#{$1}_at") || column("#{$1}_date") || column("#{$1}_on")) && col.type.in?([:date, :datetime, :time, :timestamp])
215
+ when name =~ /^(.*)_before$/ && (col = column("#{$1}_at") || column("#{$1}_date") || column("#{$1}_on")) && col.type.in?([:date, :datetime, :time, :timestamp])
216
216
  return true if check_only
217
217
 
218
218
  def_scope do |time|
@@ -220,7 +220,7 @@ module Hobo
220
220
  end
221
221
 
222
222
  # published_after(time)
223
- elsif name =~ /^(.*)_after$/ && (col = column("#{$1}_at") || column("#{$1}_date") || column("#{$1}_on")) && col.type.in?([:date, :datetime, :time, :timestamp])
223
+ when name =~ /^(.*)_after$/ && (col = column("#{$1}_at") || column("#{$1}_date") || column("#{$1}_on")) && col.type.in?([:date, :datetime, :time, :timestamp])
224
224
  return true if check_only
225
225
 
226
226
  def_scope do |time|
@@ -228,7 +228,7 @@ module Hobo
228
228
  end
229
229
 
230
230
  # published_between(time1, time2)
231
- elsif name =~ /^(.*)_between$/ && (col = column("#{$1}_at") || column("#{$1}_date") || column("#{$1}_on")) && col.type.in?([:date, :datetime, :time, :timestamp])
231
+ when name =~ /^(.*)_between$/ && (col = column("#{$1}_at") || column("#{$1}_date") || column("#{$1}_on")) && col.type.in?([:date, :datetime, :time, :timestamp])
232
232
  return true if check_only
233
233
 
234
234
  def_scope do |time1, time2|
@@ -236,12 +236,12 @@ module Hobo
236
236
  end
237
237
 
238
238
  # active (a lifecycle state)
239
- elsif @klass.has_lifecycle? && name.to_sym.in?(@klass::Lifecycle.state_names)
239
+ when @klass.has_lifecycle? && name.to_sym.in?(@klass::Lifecycle.state_names)
240
240
  return true if check_only
241
241
 
242
242
  if @klass::Lifecycle.state_names.length == 1
243
243
  # nothing to check for - create a dummy scope
244
- def_scope { @klass.where '' }
244
+ def_scope { @klass.scoped }
245
245
  true
246
246
  else
247
247
  def_scope do
@@ -250,104 +250,94 @@ module Hobo
250
250
  end
251
251
 
252
252
  # self is / is not
253
- elsif name == "is"
253
+ when name == "is"
254
254
  return true if check_only
255
255
 
256
256
  def_scope do |record|
257
257
  @klass.where "#{@klass.table_name}.#{@klass.primary_key} = ?", record
258
258
  end
259
259
 
260
- elsif name == "is_not"
260
+ when name == "is_not"
261
261
  return true if check_only
262
262
 
263
263
  def_scope do |record|
264
264
  @klass.where "#{@klass.table_name}.#{@klass.primary_key} <> ?", record
265
265
  end
266
266
 
267
- else
268
-
269
- case name
270
267
 
271
- when "by_most_recent"
272
- return true if check_only
268
+ when name == "by_most_recent"
269
+ return true if check_only
273
270
 
274
- def_scope do
275
- @klass.order "#{@klass.table_name}.created_at DESC"
276
- end
271
+ def_scope do
272
+ @klass.order "#{@klass.table_name}.created_at DESC"
273
+ end
277
274
 
278
- when "recent"
279
- return true if check_only
275
+ when name == "recent"
276
+ return true if check_only
280
277
 
281
- if "created_at".in?(@klass.columns.*.name)
282
- def_scope do |*args|
283
- count = args.first || 6
284
- @klass.order("#{@klass.table_name}.created_at DESC").limit(count)
285
- end
286
- else
287
- def_scope do |*args|
288
- count = args.first || 6
289
- limit(count)
290
- end
278
+ if "created_at".in?(@klass.columns.*.name)
279
+ def_scope do |*args|
280
+ count = args.first || 6
281
+ @klass.order("#{@klass.table_name}.created_at DESC").limit(count)
291
282
  end
292
-
293
- when "order_by"
294
- return true if check_only
295
-
296
- klass = @klass
283
+ else
297
284
  def_scope do |*args|
298
- field, asc = args
299
- type = klass.attr_type(field)
300
- if type.nil? #a virtual attribute from an SQL alias, e.g., 'total' from 'COUNT(*) AS total'
301
- colspec = "#{field}" # don't prepend the table name
302
- elsif type.respond_to?(:name_attribute) && (name = type.name_attribute)
303
- include = field
304
- colspec = "#{type.table_name}.#{name}"
305
- else
306
- colspec = "#{klass.table_name}.#{field}"
307
- end
308
- @klass.includes(include).order("#{colspec} #{asc._?.upcase}")
285
+ count = args.first || 6
286
+ limit(count)
309
287
  end
288
+ end
310
289
 
290
+ when name == "order_by"
291
+ # DEPRECATED: use :order instead.
292
+ Rails.logger.warn "Automatic scope :order_by has been deprecated: use :order instead."
293
+ return true if check_only
311
294
 
312
- when "include"
313
- # DEPRECATED: it clashes with Module.include when called on an ActiveRecord::Relation
314
- # after a scope chain, if you didn't call it on the class itself first
315
- Rails.logger.warn "Automatic scope :include has been deprecated: use :including instead."
316
- return true if check_only
317
-
318
- def_scope do |inclusions|
319
- @klass.includes(inclusions)
295
+ klass = @klass
296
+ def_scope do |*args|
297
+ field, asc = args
298
+ type = klass.attr_type(field)
299
+ if type.nil? #a virtual attribute from an SQL alias, e.g., 'total' from 'COUNT(*) AS total'
300
+ colspec = "#{field}" # don't prepend the table name
301
+ elsif type.respond_to?(:name_attribute) && (name = type.name_attribute)
302
+ include = field
303
+ colspec = "#{type.table_name}.#{name}"
304
+ else
305
+ colspec = "#{klass.table_name}.#{field}"
320
306
  end
307
+ @klass.includes(include).order("#{colspec} #{asc._?.upcase}")
308
+ end
321
309
 
322
- when "including"
323
- return true if check_only
324
-
325
- def_scope do |inclusions|
326
- @klass.includes(inclusions)
327
- end
310
+ when name == "include"
311
+ # DEPRECATED: it clashes with Module.include when called on an ActiveRecord::Relation
312
+ # after a scope chain, if you didn't call it on the class itself first
313
+ Rails.logger.warn "Automatic scope :include has been deprecated: use :includes instead."
314
+ return true if check_only
328
315
 
329
- when "search"
330
- return true if check_only
316
+ def_scope do |inclusions|
317
+ @klass.includes(inclusions)
318
+ end
331
319
 
332
- def_scope do |query, *fields|
333
- match_keyword = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
320
+ when name == "search"
321
+ return true if check_only
334
322
 
335
- words = query.split
336
- args = []
337
- word_queries = words.map do |word|
338
- field_query = '(' + fields.map { |field| "(#{@klass.table_name}.#{field} #{match_keyword} ?)" }.join(" OR ") + ')'
339
- args += ["%#{word}%"] * fields.length
340
- field_query
341
- end
323
+ def_scope do |query, *fields|
324
+ match_keyword = ::ActiveRecord::Base.connection.adapter_name == "PostgreSQL" ? "ILIKE" : "LIKE"
342
325
 
343
- @klass.where *([word_queries.join(" AND ")] + args)
326
+ words = query.split
327
+ args = []
328
+ word_queries = words.map do |word|
329
+ field_query = '(' + fields.map { |field| "(#{@klass.table_name}.#{field} #{match_keyword} ?)" }.join(" OR ") + ')'
330
+ args += ["%#{word}%"] * fields.length
331
+ field_query
344
332
  end
345
333
 
346
- else
347
- matched_scope = false
334
+ @klass.where *([word_queries.join(" AND ")] + args)
348
335
  end
349
336
 
337
+ else
338
+ matched_scope = false
350
339
  end
340
+
351
341
  matched_scope
352
342
  end
353
343
 
@@ -53,7 +53,7 @@ model_key = model.to_s.underscore
53
53
  <view:<%= creator_attribute %> param="creator"/>
54
54
  <% end -%>
55
55
  <% if primary_collection -%>
56
- <ht key="<%= primary_collection.to_s.underscore %>.collection.count" count="&this.<%= primary_collection %>.size">
56
+ <ht key="<%= model.reflect_on_association(primary_collection).klass.to_s.underscore %>.collection.count" count="&this.<%= primary_collection %>.size">
57
57
  <count:<%= primary_collection%> param/>
58
58
  </ht>
59
59
  <% end -%>
@@ -177,7 +177,7 @@ end
177
177
  <% if collection -%>
178
178
  <section param="collection-section">
179
179
  <h3 param="collection-heading">
180
- <ht key="<%= collection.to_s.underscore %>.collection.heading" count="&this.<%= collection.to_s %>.count" >
180
+ <ht key="<%= collection_class.to_s.underscore %>.collection.heading" count="&this.<%= collection.to_s %>.count" >
181
181
  <human-collection-name collection="<%= collection %>" your/>
182
182
  </ht>
183
183
  </h3>
@@ -190,21 +190,21 @@ end
190
190
  <% if add_link -%>
191
191
 
192
192
  <a:<%= collection %> action="new" if="&can_create?(@<%= model.name.underscore %>.<%= collection %>)" param="new-link">
193
- <ht key="<%= collection.to_s.underscore %>.actions.new" count="1">
194
- New <%= collection.to_s.singularize.titleize %>
193
+ <ht key="<%= collection_class.to_s.underscore %>.actions.new" count="1">
194
+ New <%= collection_class.to_s.titleize %>
195
195
  </ht>
196
196
  </a:<%= collection %>>
197
197
  <% elsif add_form -%>
198
198
 
199
199
  <section param="add-to-collection" if="&can_create?(@<%= model.name.underscore %>.<%= collection %>)">
200
200
  <h3 param="add-form-heading">
201
- <ht key="<%= collection.to_s.underscore %>.collection.add_form_heading" count="1">
202
- Add <%= a_or_an collection.to_s.singularize.titleize %>
201
+ <ht key="<%= collection_class.to_s.underscore %>.collection.add_form_heading" count="1">
202
+ Add <%= a_or_an collection_class.to_s.titleize %>
203
203
  </ht>
204
204
  </h3>
205
205
  <form with="&@<%= collection_class.name.underscore %> || new_for_current_user(@<%= model.name.underscore %>.<%= collection %>)" owner="<%= owner %>" without-cancel param>
206
206
  <field-list: skip="<%= owner %>"/>
207
- <submit: label="#{ht '<%= sq_escape collection.to_s.underscore %>.actions.add', :default=>['Add'] }"/>
207
+ <submit: label="#{ht '<%= sq_escape collection_class.to_s.underscore %>.actions.add', :default=>['Add'] }"/>
208
208
  </form>
209
209
  </section>
210
210
  <% end -%>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo
3
3
  version: !ruby/object:Gem::Version
4
- hash: -1637108444
4
+ hash: -1637108443
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
9
  - 0
10
- - pre22
11
- version: 1.3.0.pre22
10
+ - pre23
11
+ version: 1.3.0.pre23
12
12
  platform: ruby
13
13
  authors:
14
14
  - Tom Locke
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-27 00:00:00 -04:00
19
+ date: 2010-11-28 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -59,13 +59,13 @@ dependencies:
59
59
  requirements:
60
60
  - - "="
61
61
  - !ruby/object:Gem::Version
62
- hash: -1637108444
62
+ hash: -1637108443
63
63
  segments:
64
64
  - 1
65
65
  - 3
66
66
  - 0
67
- - pre22
68
- version: 1.3.0.pre22
67
+ - pre23
68
+ version: 1.3.0.pre23
69
69
  type: :runtime
70
70
  version_requirements: *id003
71
71
  - !ruby/object:Gem::Dependency
@@ -76,13 +76,13 @@ dependencies:
76
76
  requirements:
77
77
  - - "="
78
78
  - !ruby/object:Gem::Version
79
- hash: -1637108444
79
+ hash: -1637108443
80
80
  segments:
81
81
  - 1
82
82
  - 3
83
83
  - 0
84
- - pre22
85
- version: 1.3.0.pre22
84
+ - pre23
85
+ version: 1.3.0.pre23
86
86
  type: :runtime
87
87
  version_requirements: *id004
88
88
  - !ruby/object:Gem::Dependency
@@ -93,13 +93,13 @@ dependencies:
93
93
  requirements:
94
94
  - - "="
95
95
  - !ruby/object:Gem::Version
96
- hash: -1637108444
96
+ hash: -1637108443
97
97
  segments:
98
98
  - 1
99
99
  - 3
100
100
  - 0
101
- - pre22
102
- version: 1.3.0.pre22
101
+ - pre23
102
+ version: 1.3.0.pre23
103
103
  type: :runtime
104
104
  version_requirements: *id005
105
105
  - !ruby/object:Gem::Dependency
@@ -266,13 +266,13 @@ files:
266
266
  - lib/hobo/extensions/action_view/translation_helper.rb
267
267
  - lib/hobo/extensions/active_model/name.rb
268
268
  - lib/hobo/extensions/active_model/translation.rb
269
- - lib/hobo/extensions/active_record/association_collection.rb
270
- - lib/hobo/extensions/active_record/association_proxy.rb
271
- - lib/hobo/extensions/active_record/association_reflection.rb
269
+ - lib/hobo/extensions/active_record/associations/collection.rb
270
+ - lib/hobo/extensions/active_record/associations/proxy.rb
271
+ - lib/hobo/extensions/active_record/associations/reflection.rb
272
+ - lib/hobo/extensions/active_record/associations/scope.rb
272
273
  - lib/hobo/extensions/active_record/hobo_methods.rb
273
274
  - lib/hobo/extensions/active_record/permissions.rb
274
275
  - lib/hobo/extensions/active_record/relation_with_origin.rb
275
- - lib/hobo/extensions/active_record/scopes.rb
276
276
  - lib/hobo/extensions/array.rb
277
277
  - lib/hobo/extensions/enumerable.rb
278
278
  - lib/hobo/extensions/i18n.rb
@@ -1,19 +0,0 @@
1
- class ActiveRecord::Reflection::AssociationReflection
2
-
3
- alias_method :association_name, :name
4
-
5
- def klass_with_create_polymorphic_class
6
- if options[:polymorphic]
7
- begin
8
- klass_without_create_polymorphic_class
9
- rescue NameError => e
10
- Object.class_eval "class #{e.missing_name} < ActiveRecord::Base; set_table_name '#{active_record.name.tableize}'; end"
11
- e.missing_name.constantize
12
- end
13
- else
14
- klass_without_create_polymorphic_class
15
- end
16
- end
17
- alias_method_chain :klass, :create_polymorphic_class
18
-
19
- end
@@ -1,31 +0,0 @@
1
- # Add support for :scope => :my_scope to associations
2
-
3
- ActiveRecord::Associations::ThroughAssociationScope.class_eval do
4
-
5
- def construct_scope_with_scope
6
- s = construct_scope_without_scope
7
- s[:find][:scope] = @reflection.options[:scope]
8
- s
9
- end
10
- alias_method_chain :construct_scope, :scope
11
-
12
- end
13
-
14
- ActiveRecord::SpawnMethods.class_eval do
15
-
16
- def apply_finder_options_with_scope(options)
17
- scopes = []
18
- Array.wrap(options.delete(:scope)).each do |s|
19
- if s.is_a?(Hash)
20
- s.each_pair{|k,v| scopes << [k,v] }
21
- else
22
- scopes << [s]
23
- end
24
- end
25
- relation = apply_finder_options_without_scope(options)
26
- return relation if scopes.empty?
27
- scopes.inject(relation) {|r, s| r.send *s }
28
- end
29
- alias_method_chain :apply_finder_options, :scope
30
-
31
- end