active_scaffold 3.1.12 → 3.1.13

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.
@@ -49,7 +49,7 @@ class ActiveScaffold::Bridges::RecordSelect
49
49
 
50
50
  def active_scaffold_record_select_autocomplete(column, options)
51
51
  record_select_options = active_scaffold_input_text_options(options).merge(
52
- :controller => remote_controller
52
+ :controller => active_scaffold_controller_for(@record.class).controller_path
53
53
  )
54
54
  html = record_select_autocomplete(options[:name], @record, record_select_options)
55
55
  html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
@@ -33,17 +33,10 @@ class ActiveScaffold::Bridges::RecordSelect
33
33
  params.merge!({column.association.primary_key_name => ''})
34
34
  end
35
35
 
36
- record_select_options = active_scaffold_input_text_options(
37
- :controller => remote_controller,
38
- :id => options[:id],
39
- :class => options[:class].gsub(/update_form/, '')
36
+ record_select_options = active_scaffold_input_text_options(options).merge(
37
+ :controller => remote_controller
40
38
  )
41
39
  record_select_options.merge!(column.options)
42
- if options['data-update_url']
43
- record_select_options[:onchange] = %|function(id, label) {
44
- ActiveScaffold.update_column(null, "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
45
- }|
46
- end
47
40
 
48
41
  html = if multiple
49
42
  record_multi_select_field(options[:name], value || [], record_select_options)
@@ -55,18 +48,11 @@ class ActiveScaffold::Bridges::RecordSelect
55
48
  end
56
49
 
57
50
  def active_scaffold_record_select_autocomplete(column, options)
58
- record_select_options = active_scaffold_input_text_options(
59
- :controller => active_scaffold_controller_for(@record.class).controller_path,
60
- :id => options[:id],
61
- :class => options[:class].gsub(/update_form/, '')
51
+ remote_controller = active_scaffold_controller_for(column.association.klass).controller_path
52
+ record_select_options = active_scaffold_input_text_options(options).merge(
53
+ :controller => remote_controller
62
54
  )
63
- if options['data-update_url']
64
- record_select_options[:onchange] = %|function(id, label) {
65
- ActiveScaffold.update_column(null, "#{options['data-update_url']}", #{options['data-update_send_form'].to_json}, "#{options[:id]}", id);
66
- }|
67
- end
68
-
69
- html = record_select_autocomplete(options[:name], value, record_select_options)
55
+ html = record_select_autocomplete(options[:name], @record, record_select_options)
70
56
  html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
71
57
  html
72
58
  end
@@ -5,7 +5,7 @@
5
5
  ActiveRecord::Reflection::AssociationReflection.class_eval do
6
6
  def klass_with_sti(*opts)
7
7
  sti_col = klass.inheritance_column
8
- if (h = opts.first).is_a? Hash and (passed_type = ( h[sti_col] || h[sti_col.to_sym] )) and (new_klass = active_record.send(:compute_type, passed_type)) < klass
8
+ if sti_col and (h = opts.first).is_a? Hash and (passed_type = ( h[sti_col] || h[sti_col.to_sym] )) and (new_klass = active_record.send(:compute_type, passed_type)) < klass
9
9
  new_klass
10
10
  else
11
11
  klass
@@ -0,0 +1,22 @@
1
+ # Bugfix: building an sti model from an association fails
2
+ # https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6306-collection-associations-build-method-not-supported-for-sti
3
+ # https://github.com/rails/rails/issues/815
4
+ # https://github.com/rails/rails/pull/1686
5
+ ActiveRecord::Reflection::AssociationReflection.class_eval do
6
+ def klass_with_sti(*opts)
7
+ sti_col = klass.inheritance_column
8
+ if (h = opts.first).is_a? Hash and (passed_type = ( h[sti_col] || h[sti_col.to_sym] )) and (new_klass = active_record.send(:compute_type, passed_type)) < klass
9
+ new_klass
10
+ else
11
+ klass
12
+ end
13
+ end
14
+ def build_association(*opts, &block)
15
+ self.original_build_association_called = true
16
+ klass_with_sti(*opts).new(*opts, &block)
17
+ end
18
+ def create_association(*opts, &block)
19
+ self.original_build_association_called = true
20
+ klass_with_sti(*opts).create(*opts, &block)
21
+ end
22
+ end
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 1
5
- PATCH = 12
5
+ PATCH = 13
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
8
  - 1
9
- - 12
10
- version: 3.1.12
9
+ - 13
10
+ version: 3.1.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Many, see README
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-19 00:00:00 Z
18
+ date: 2011-12-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
@@ -348,6 +348,7 @@ files:
348
348
  - lib/active_scaffold/extensions/reverse_associations.rb~
349
349
  - lib/active_scaffold/extensions/routing_mapper.rb~
350
350
  - lib/active_scaffold/extensions/unsaved_associated.rb~
351
+ - lib/active_scaffold/extensions/active_association_reflection.rb~
351
352
  - lib/active_scaffold/paginator.rb
352
353
  - lib/active_scaffold/responds_to_parent.rb
353
354
  - lib/active_scaffold/version.rb