inline_forms 1.4.6 → 1.4.7

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.
@@ -53,10 +53,10 @@ class InlineFormsController < ApplicationController
53
53
  @PER_PAGE = 5 unless @parent_class.nil?
54
54
  # if the parent_class is not nill, we are in associated list and we don't search there.
55
55
  # also, make sure the Model that you want to do a search on has a :name attribute. TODO
56
- if @parent_class.nil?
56
+ if @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?
57
57
  conditions = [ @Klass.to_s.tableize + "." + @Klass.order_by_clause + " like ?", "%#{params[:search]}%" ]
58
58
  else
59
- foreign_key = @Klass.first.association(@parent_class.underscore.to_sym).reflection.options[:foreign_key] || @parent_class.foreign_key
59
+ foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
60
60
  conditions = [ "#{foreign_key} = ?", @parent_id ]
61
61
  end
62
62
  # if we are using cancan, then make sure to select only accessible records
@@ -84,10 +84,12 @@ class InlineFormsController < ApplicationController
84
84
  @object = @Klass.new
85
85
  @update_span = params[:update]
86
86
  @parent_class = params[:parent_class]
87
- unless @parent_class.nil?
87
+ begin
88
88
  @parent_id = params[:parent_id]
89
- @object[@parent_class.foreign_key] = @parent_id
90
- end
89
+ foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
90
+ @object[foreign_key] = @parent_id
91
+ end unless @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?
92
+
91
93
  @object.inline_forms_attribute_list = @inline_forms_attribute_list if @inline_forms_attribute_list
92
94
  respond_to do |format|
93
95
  format.js { }
@@ -120,10 +122,10 @@ class InlineFormsController < ApplicationController
120
122
  @parent_id = params[:parent_id]
121
123
  @PER_PAGE = 5 unless @parent_class.nil?
122
124
  # for the logic behind the :conditions see the #index method.
123
- if @parent_class.nil?
125
+ if @parent_class.nil? || @Klass.reflect_on_association(@parent_class.underscore.to_sym).nil?
124
126
  conditions = [ @Klass.to_s.tableize + "." + @Klass.order_by_clause + " like ?", "%#{params[:search]}%" ]
125
127
  else
126
- foreign_key = object.association(@parent_class.underscore.to_sym).reflection.options[:foreign_key] || @parent_class.foreign_key
128
+ foreign_key = @Klass.reflect_on_association(@parent_class.underscore.to_sym).options[:foreign_key] || @parent_class.foreign_key
127
129
  conditions = [ "#{foreign_key} = ?", @parent_id ]
128
130
  object[foreign_key] = @parent_id
129
131
  end
@@ -24,7 +24,7 @@ def dropdown_edit(object, attribute)
24
24
  end
25
25
 
26
26
  def dropdown_update(object, attribute)
27
- foreign_key = object.association(attribute.to_sym).reflection.options[:foreign_key] || attribute.to_s.foreign_key.to_sym
27
+ foreign_key = object.class.reflect_on_association(attribute.to_sym).options[:foreign_key] || attribute.to_s.foreign_key.to_sym
28
28
  object[foreign_key] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_s.foreign_key.to_sym]
29
29
  end
30
30
 
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "1.4.6"
3
+ VERSION = "1.4.7"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.6
4
+ version: 1.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -202,7 +202,6 @@ files:
202
202
  - lib/app/helpers/form_elements/geo_code_curacao.rb
203
203
  - lib/app/helpers/form_elements/image_field.rb
204
204
  - lib/app/helpers/form_elements/info.rb
205
- - lib/app/helpers/form_elements/infoadmin.rb
206
205
  - lib/app/helpers/form_elements/plain_text_area.rb
207
206
  - lib/app/helpers/form_elements/question_list.rb
208
207
  - lib/app/helpers/form_elements/radio_button.rb
@@ -1,23 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- # FIXME not needed here, since this is only used in the views InlineForms::SPECIAL_COLUMN_TYPES[:info]=:string
3
-
4
- def infoadmin_show(object, attribute)
5
- object.send(attribute)._presentation rescue ''
6
- end
7
-
8
- def infoadmin_edit(object, attribute)
9
- object.send('build_' + attribute.to_s) unless object.send(attribute)
10
- o = object.send(attribute).class.name.constantize
11
- if cancan_enabled?
12
- values = o.accessible_by(current_ability).order(o.order_by_clause)
13
- else
14
- values = o.order(o.order_by_clause)
15
- end
16
- # the leading underscore is to avoid name conflicts, like 'email' and 'email_type' will result in 'email' and 'email[email_type_id]' in the form!
17
- collection_select( ('_' + object.class.to_s.underscore).to_sym, attribute.to_s.foreign_key.to_sym, values, 'id', '_presentation', :selected => object.send(attribute).id)
18
- end
19
-
20
- def infoadmin_update(object, attribute)
21
- object[attribute.to_s.foreign_key.to_sym] = params[('_' + object.class.to_s.underscore).to_sym][attribute.to_s.foreign_key.to_sym]
22
- end
23
-