inline_forms 6.2.14 → 6.3.3

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +67 -0
  3. data/README.rdoc +5 -1
  4. data/Rakefile +12 -1
  5. data/app/helpers/form_elements/audio_field.rb +1 -1
  6. data/app/helpers/form_elements/check_box.rb +1 -1
  7. data/app/helpers/form_elements/check_list.rb +2 -2
  8. data/app/helpers/form_elements/chicas_dropdown_with_family_members.rb +1 -1
  9. data/app/helpers/form_elements/ckeditor.rb +2 -1
  10. data/app/helpers/form_elements/date.rb +1 -1
  11. data/app/helpers/form_elements/decimal_field.rb +1 -1
  12. data/app/helpers/form_elements/devise_password_field.rb +1 -1
  13. data/app/helpers/form_elements/dropdown.rb +1 -1
  14. data/app/helpers/form_elements/dropdown_with_integers.rb +1 -1
  15. data/app/helpers/form_elements/dropdown_with_other.rb +1 -1
  16. data/app/helpers/form_elements/dropdown_with_values.rb +1 -1
  17. data/app/helpers/form_elements/dropdown_with_values_with_stars.rb +1 -1
  18. data/app/helpers/form_elements/file_field.rb +1 -1
  19. data/app/helpers/form_elements/geo_code_curacao.rb +1 -1
  20. data/app/helpers/form_elements/image_field.rb +1 -1
  21. data/app/helpers/form_elements/integer_field.rb +1 -1
  22. data/app/helpers/form_elements/kansen_slider.rb +1 -1
  23. data/app/helpers/form_elements/money_field.rb +1 -1
  24. data/app/helpers/form_elements/month_select.rb +1 -1
  25. data/app/helpers/form_elements/month_year_picker.rb +1 -1
  26. data/app/helpers/form_elements/move.rb +1 -1
  27. data/app/helpers/form_elements/multi_image_field.rb +1 -1
  28. data/app/helpers/form_elements/plain_text_area.rb +1 -1
  29. data/app/helpers/form_elements/question_list.rb +2 -2
  30. data/app/helpers/form_elements/radio_button.rb +1 -1
  31. data/app/helpers/form_elements/scale_with_integers.rb +1 -1
  32. data/app/helpers/form_elements/scale_with_values.rb +1 -1
  33. data/app/helpers/form_elements/simple_file_field.rb +1 -1
  34. data/app/helpers/form_elements/slider_with_values.rb +1 -1
  35. data/app/helpers/form_elements/text_area.rb +4 -3
  36. data/app/helpers/form_elements/text_area_without_ckeditor.rb +1 -1
  37. data/app/helpers/form_elements/text_field.rb +1 -1
  38. data/app/helpers/form_elements/time.rb +1 -1
  39. data/app/helpers/inline_forms_helper.rb +16 -29
  40. data/app/views/inline_forms/_close.html.erb +2 -2
  41. data/app/views/inline_forms/_edit.html.erb +4 -3
  42. data/app/views/inline_forms/_new.html.erb +2 -2
  43. data/bin/inline_forms_installer_core.rb +38 -6
  44. data/inline_forms.gemspec +3 -1
  45. data/lib/inline_forms/form_element_from_callee.rb +10 -0
  46. data/lib/inline_forms/version.rb +1 -1
  47. data/lib/inline_forms.rb +1 -13
  48. data/lib/installer_templates/example_app_tests/test/example_app/example_integration_test_case.rb +36 -0
  49. data/lib/installer_templates/example_app_tests/test/integration/example_app_guest_access_test.rb +21 -0
  50. data/lib/installer_templates/example_app_tests/test/integration/example_app_photos_test.rb +22 -0
  51. data/lib/installer_templates/example_app_tests/test/integration/example_app_routing_test.rb +15 -0
  52. data/lib/installer_templates/example_app_tests/test/models/example_app_apartment_photo_test.rb +26 -0
  53. data/test/form_element_from_callee_test.rb +73 -0
  54. data/test/inline_edit_polymorphic_path_test.rb +81 -0
  55. data/test/test_helper.rb +6 -0
  56. metadata +35 -9
  57. data/app/helpers/form_elements/absence_list.rb +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47c91a53a6fffc56db106874c00571182582ea6791690a8aa6817d3b297d8a2c
4
- data.tar.gz: ab879feabb9a8104ed11f8d7a3fbf7feffddc8860f13d9e52075b07eb496a24b
3
+ metadata.gz: 6dbffa35c00698de69d27e5e6c51ac9a8ffbbab983e5a7092d129347c790f3ae
4
+ data.tar.gz: 78cec43c0ea51439b4c065a9bb6ef2738ee2b00193e07c4b62808afa8466cd20
5
5
  SHA512:
6
- metadata.gz: d4b6061360a62fbce0eaed156a1ff23645fa927b7e5a82b0065b95ff8a262991dfb21a013b6e0e5816ad4ef8f11617347af5cd9da20ed45ebaf11d8647477f68
7
- data.tar.gz: 73f93169d282fade1c1ac0cd16dbd83fb582b4c13e5fcea0e9f0b15424880e126cef58ab6d8e2eb3bf6d99f33971f8b3becd2d31d0bf4caa5aef406447b48430
6
+ metadata.gz: b54ec339cff6f10c8c7dc2aac2392337ca49193e1b6e99516f280d22d95601c0802ce00d47b75746ca2615cef8a420ca0c523778042372b2363926d121f2057b
7
+ data.tar.gz: f8478bda112dd62f3baf447cf620a5394b766046cd1324973bfc9fe5db8f75ff4d772d32a5fc21b165d9a8466d954d33daeccf7b17f11fc222eec23f712990f0
data/CHANGELOG.md ADDED
@@ -0,0 +1,67 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file.
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [6.3.3] - 2026-05-03
8
+
9
+ ### Added
10
+
11
+ - **`--example` installs regression tests** under `test/example_app/` and `test/integration/example_app_*_test.rb`, plus model coverage for the generated Photo/Apartment resources. Run them with **`bundle exec rails test`** in the new app.
12
+
13
+ ### Changed
14
+
15
+ - **Example installer** no longer runs **`bundle exec rails s`** at the end (it blocked the shell). Start the server manually when you want to use the browser.
16
+
17
+ ### Fixed
18
+
19
+ - **Sqlite `database.yml`** now includes a **`test`** database (`db/test.sqlite3`) so **`bundle exec rails test`** works in generated sqlite apps.
20
+ - Generated apps add a **`test`** Bundler group with **`minitest ~> 5.25`** so Rails 6.1’s test runner stays compatible (avoids Minitest 6 / **`railties`** **`line_filtering`** and parallelization API mismatches).
21
+
22
+ ## [6.3.2] - 2026-05-03
23
+
24
+ ### Fixed
25
+
26
+ - **Application template (`bin/inline_forms_installer_core.rb`):** generated apps use **`rails-i18n ~> 7.0`** from RubyGems instead of the **`svenfuchs/rails-i18n`** git default branch, which targets Rails 8+ and could not be resolved with pinned **`rails` 6.1.3.1**.
27
+ - **Same:** development **`sqlite3`** is pinned to **`~> 1.4`** so it matches ActiveRecord 6.1’s adapter expectation (avoids **`sqlite3` 2.x** activation errors during generators and boot).
28
+ - **Same:** **`sleep 1`** after **`paper_trail:install`** (two migrations in one second) and between translation **`inline_forms`** generators so migration version numbers stay unique.
29
+ - **Same:** when **`using_sqlite`** is true, run **`paper_trail:install --with-changes`** only (omit **`--with-mysql`**). The MySQL/InnoDB table options in the PaperTrail migration are invalid on SQLite and broke **`db:migrate`** for the sqlite example app.
30
+
31
+ ## [6.3.1] - 2026-05-03
32
+
33
+ ### Changed
34
+
35
+ - `**InlineFormsHelper#link_to_inline_edit**` uses `**edit_polymorphic_path**` instead of `**send('edit_' + object.class.to_s.underscore + '_path', …)**`.
36
+ - `**InlineFormsHelper#close_link**` and `**#link_to_destroy**` use `**polymorphic_path(object, …)**` instead of `**send(object.class.to_s.underscore + '_path', …)**`.
37
+ - Partial templates `**_close.html.erb**`, `**_edit.html.erb**`, and `**_new.html.erb**` use `**polymorphic_path**` for member and collection URLs instead of building helper names with `**send**`.
38
+ - `**_edit.html.erb**` form and cancel links now pass the record into `**polymorphic_path(@object, …)**` so the member path includes the resource id (required for conventional `**resources**` routes).
39
+
40
+ ### Compatibility
41
+
42
+ - Intended to be **non-breaking** for typical ActiveRecord models with standard `**resources :model**` routing: URLs match Rails’ named helpers (`**edit_*_path**`, `**article_path**`, `**articles_path**`, etc.). Paths are derived from `**model_name**` / `**singular_route_key**` instead of `**class.name.underscore**`, which can differ only in unusual setups (e.g. a custom `**model_name**` that does not match the previous string).
43
+
44
+ ### Development
45
+
46
+ - `**test/inline_edit_polymorphic_path_test.rb**` asserts parity between polymorphic helpers and named `**edit_article_path**`, `**article_path**`, and `**articles_path**` for a minimal `**resources :articles**` route set (no full app boot).
47
+
48
+ ## [6.3.0] - 2026-05-03
49
+
50
+ ### Removed
51
+
52
+ - Project-specific `absence_list` form element (`app/helpers/form_elements/absence_list.rb`). Applications that still need it should copy the old implementation into their own codebase.
53
+
54
+ ### Changed
55
+
56
+ - `**InlineFormsHelper#link_to_inline_edit**` now requires keyword argument `**from_callee:**` (pass `**__callee__**` from the enclosing `*_show` method). The form element name for the edit request is derived with `String#delete_suffix('_show')` after stripping a leading `block in` prefix when present. This replaces stack inspection via `Kernel#calling_method` / `caller` parsing.
57
+ - `**Kernel` patches** for `this_method` and `calling_method` were removed from `lib/inline_forms.rb` and `app/helpers/inline_forms_helper.rb`.
58
+
59
+ ### Upgrade notes
60
+
61
+ - **Breaking:** Any custom code that called `link_to_inline_edit` with a fourth positional `form_element` argument must switch to `from_callee: __callee__` when the call is made from a `*_show` helper, or pass the appropriate callee symbol for your naming convention.
62
+ - **Breaking:** Models or apps that referenced the `absence_list` form element from this gem must drop that reference or vendor the removed helper.
63
+
64
+ ### Development
65
+
66
+ - Run `bundle install` then `rake` (or `rake test`) to execute Minitest for `InlineForms.form_element_string_from_callee` (no Rails boot). The Rake task uses verbose mode so each test prints on its own line; failed assertions show the explanatory message from the test file.
67
+ - For end-to-end checks, generate a disposable app with `**bin/inline_forms create MyApp -d sqlite`** (uses RVM unless `--no-rvm`), or add the gem with `**gem "inline_forms", path: "/path/to/inline_forms"**` in a Rails app’s Gemfile, run `**rails g inline_forms …**`, migrate, and exercise the UI in the browser.
data/README.rdoc CHANGED
@@ -18,7 +18,7 @@ If you want to install the example application:
18
18
 
19
19
  inline_forms create MyApp -d sqlite --example
20
20
 
21
- Then point your browser to http://localhost:3000/apartments and log in with admin@example.com / admin999
21
+ Then point your browser to http://localhost:3000/apartments and log in with admin@example.com / admin999. The example also adds integration and model tests; run +bundle exec rails test+ in +MyApp+, then start the server with +bundle exec rails s+ when you want the UI.
22
22
 
23
23
  You can install the example application manually if you like:
24
24
 
@@ -32,6 +32,10 @@ You can install the example application manually if you like:
32
32
 
33
33
  Then point your browser to http://localhost:3000/apartments and log in with admin@example.com / admin999
34
34
 
35
+ == Generated application +rails-i18n+
36
+
37
+ New apps get +rails-i18n+ from RubyGems (+ '~> 7.0'+), not from the +svenfuchs/rails-i18n+ Git repository. Release line 7.0.x declares +railties+ between 6 and 8, which matches the template’s Rails 6.1.3.1. The upstream repository’s default branch is aimed at newer Rails and would pull in +railties+ 8+, which cannot be resolved together with Rails 6.1.
38
+
35
39
  = Build a vagrant virtualbox box for easier development
36
40
 
37
41
  Go ahead and unzip lib/vagrant/vagrantbox-inline_forms.zip. Enter the created directory with
data/Rakefile CHANGED
@@ -1,2 +1,13 @@
1
- require 'bundler'
1
+ require "bundler"
2
2
  Bundler::GemHelper.install_tasks
3
+
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.test_files = FileList["test/**/*_test.rb"]
9
+ t.verbose = true
10
+ t.warning = true
11
+ end
12
+
13
+ task default: :test
@@ -11,7 +11,7 @@ def audio_field_show(object, attribute)
11
11
  audio_html = audio_tag(o.send(:url), autoplay: false, controls: true)
12
12
  end
13
13
  end
14
- link_to_edit = link_to_inline_edit object, attribute, msg
14
+ link_to_edit = link_to_inline_edit object, attribute, msg, from_callee: __callee__
15
15
  if cancan_disabled? || ( can? :update, object, attribute )
16
16
  "#{audio_html} #{link_to_edit}".html_safe
17
17
  else
@@ -3,7 +3,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:check_box]=:boolean
3
3
  # boolean, bit unaptly named check_box
4
4
  def check_box_show(object, attribute)
5
5
  values = attribute_values(object, attribute)
6
- link_to_inline_edit object, attribute, values[object.send(attribute) ? 1 : 0 ][1]
6
+ link_to_inline_edit object, attribute, values[object.send(attribute) ? 1 : 0 ][1], from_callee: __callee__
7
7
  end
8
8
 
9
9
  def check_box_edit(object, attribute)
@@ -4,10 +4,10 @@ InlineForms::SPECIAL_COLUMN_TYPES[:check_list]=:no_migration
4
4
  # checklist
5
5
  def check_list_show(object, attribute)
6
6
  out = ''
7
- out = link_to_inline_edit(object, attribute, "<i class='fi-plus'></i>".html_safe) if object.send(attribute).empty?
7
+ out = link_to_inline_edit(object, attribute, "<i class='fi-plus'></i>".html_safe, from_callee: __callee__) if object.send(attribute).empty?
8
8
  object.send(attribute).sort.each do | item |
9
9
  out << "<div class='row #{cycle('odd', 'even')}'>"
10
- out << link_to_inline_edit(object, attribute, item._presentation )
10
+ out << link_to_inline_edit(object, attribute, item._presentation, from_callee: __callee__ )
11
11
  out << '</div>'
12
12
  end
13
13
  out.html_safe
@@ -4,7 +4,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:dropdown]=:belongs_to
4
4
  # dropdown
5
5
  def chicas_dropdown_with_family_members_show(object, attribute)
6
6
  attribute_value = object.send(attribute)._dropdown_presentation rescue "<i class='fi-plus'></i>".html_safe
7
- link_to_inline_edit object, attribute, attribute_value
7
+ link_to_inline_edit object, attribute, attribute_value, from_callee: __callee__
8
8
  end
9
9
 
10
10
  def chicas_dropdown_with_family_members_edit(object, attribute)
@@ -21,7 +21,8 @@ def ckeditor_show(object, attribute)
21
21
  :class => "glass_plate",
22
22
  :title => '' ) +
23
23
  "<script>delete CKEDITOR.instances['textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}']</script>".html_safe +
24
- '</div>'.html_safe
24
+ '</div>'.html_safe,
25
+ from_callee: __callee__
25
26
  end
26
27
 
27
28
  def ckeditor_edit(object, attribute)
@@ -3,7 +3,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:date_select]=:date
3
3
 
4
4
  # date
5
5
  def date_select_show(object, attribute)
6
- link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).to_date.strftime("%d-%m-%Y")
6
+ link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).to_date.strftime("%d-%m-%Y"), from_callee: __callee__
7
7
  end
8
8
 
9
9
  def date_select_edit(object, attribute)
@@ -2,7 +2,7 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:decimal_field]=:string
3
3
 
4
4
  def decimal_field_show(object, attribute)
5
- link_to_inline_edit object, attribute, object[attribute].nil? ? "<i class='fi-plus'></i>".html_safe : object[attribute]
5
+ link_to_inline_edit object, attribute, object[attribute].nil? ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
6
6
  end
7
7
 
8
8
  def decimal_field_edit(object, attribute)
@@ -2,7 +2,7 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:devise_password_field]=:string
3
3
 
4
4
  def devise_password_field_show(object, attribute)
5
- link_to_inline_edit object, attribute, ''
5
+ link_to_inline_edit object, attribute, '', from_callee: __callee__
6
6
  end
7
7
 
8
8
  def devise_password_field_edit(object, attribute)
@@ -7,7 +7,7 @@ def dropdown_show(object, attribute)
7
7
  presentation = "_presentation"
8
8
  presentation = "_dropdown_presentation" if attr.respond_to? "_dropdown_presentation"
9
9
  attribute_value = object.send(attribute).send(presentation) rescue "<i class='fi-plus'></i>".html_safe
10
- link_to_inline_edit object, attribute, attribute_value
10
+ link_to_inline_edit object, attribute, attribute_value, from_callee: __callee__
11
11
  end
12
12
 
13
13
  def dropdown_edit(object, attribute)
@@ -7,7 +7,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_integers]=:integer
7
7
  # values must be a Range or a one-dimensional array of Integers
8
8
  def dropdown_with_integers_show(object, attribute)
9
9
  values = attribute_values(object, attribute)
10
- link_to_inline_edit object, attribute, values[object.send(attribute)][1]
10
+ link_to_inline_edit object, attribute, values[object.send(attribute)][1], from_callee: __callee__
11
11
  end
12
12
 
13
13
  def dropdown_with_integers_edit(object, attribute)
@@ -12,7 +12,7 @@ def dropdown_with_other_show(object, attribute)
12
12
  else
13
13
  attribute_value = object.send(attribute)._presentation rescue "<i class='fi-plus'></i>".html_safe
14
14
  end
15
- link_to_inline_edit object, attribute, attribute_value
15
+ link_to_inline_edit object, attribute, attribute_value, from_callee: __callee__
16
16
  end
17
17
 
18
18
  def dropdown_with_other_edit(object, attribute)
@@ -4,7 +4,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_values]=:integer
4
4
  # dropdown_with_values
5
5
  def dropdown_with_values_show(object, attribute)
6
6
  values = attribute_values(object, attribute)
7
- link_to_inline_edit object, attribute, object.send(attribute) ? t(values.assoc(object.send(attribute))[1]) : "<i class='fi-plus'></i>".html_safe
7
+ link_to_inline_edit object, attribute, object.send(attribute) ? t(values.assoc(object.send(attribute))[1]) : "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
8
8
  end
9
9
 
10
10
  def dropdown_with_values_edit(object, attribute)
@@ -4,7 +4,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:dropdown_with_values_with_stars]=:integer
4
4
  # dropdown_with_values_with_stars
5
5
  def dropdown_with_values_with_stars_show(object, attribute)
6
6
  values = attribute_values(object, attribute)
7
- link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute] == 0) ? "<i class='fi-plus'></i>".html_safe : image_tag(object[attribute].to_s + 'stars.png')
7
+ link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute] == 0) ? "<i class='fi-plus'></i>".html_safe : image_tag(object[attribute].to_s + 'stars.png'), from_callee: __callee__
8
8
  end
9
9
  def dropdown_with_values_with_stars_edit(object, attribute)
10
10
  # 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!
@@ -7,7 +7,7 @@ def file_field_show(object, attribute)
7
7
  if o.send(:present?)
8
8
  msg = "replace | <a href='#{o.send(:url)}'>#{o.send(:path).gsub(/^.*\//,'')}</a>".html_safe
9
9
  end
10
- link_to_inline_edit object, attribute, msg
10
+ link_to_inline_edit object, attribute, msg, from_callee: __callee__
11
11
  end
12
12
 
13
13
  def file_field_edit(object, attribute)
@@ -4,7 +4,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:geo_code_curacao]=:string
4
4
  # geo_code_curacao
5
5
  def geo_code_curacao_show(object, attribute)
6
6
  attribute_value = GeoCodeCuracao.new(object.send(attribute)).presentation rescue nil
7
- link_to_inline_edit object, attribute, attribute_value
7
+ link_to_inline_edit object, attribute, attribute_value, from_callee: __callee__
8
8
  end
9
9
  def geo_code_curacao_edit(object, attribute)
10
10
  attribute_value = object.send(attribute).presentation rescue nil
@@ -11,7 +11,7 @@ def image_field_show(object, attribute)
11
11
  msg = image_tag(o.send(:url))
12
12
  end
13
13
  end
14
- link_to_inline_edit object, attribute, msg
14
+ link_to_inline_edit object, attribute, msg, from_callee: __callee__
15
15
  end
16
16
 
17
17
  def image_field_edit(object, attribute)
@@ -2,7 +2,7 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:integer_field]=:integer
3
3
 
4
4
  def integer_field_show(object, attribute)
5
- link_to_inline_edit object, attribute, object[attribute].nil? ? "<i class='fi-plus'></i>".html_safe : object[attribute]
5
+ link_to_inline_edit object, attribute, object[attribute].nil? ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
6
6
  end
7
7
 
8
8
  def integer_field_edit(object, attribute)
@@ -30,7 +30,7 @@ def kansen_slider_show(object, attribute)
30
30
  </script>').html_safe
31
31
  out << "</div>".html_safe
32
32
  end
33
- link_to_inline_edit object, attribute, out
33
+ link_to_inline_edit object, attribute, out, from_callee: __callee__
34
34
  end
35
35
 
36
36
  def kansen_slider_edit(object, attribute)
@@ -2,7 +2,7 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:money_field]=:integer
3
3
 
4
4
  def money_field_show(object, attribute)
5
- link_to_inline_edit object, attribute, humanized_money_with_symbol(object.send attribute)
5
+ link_to_inline_edit object, attribute, humanized_money_with_symbol(object.send attribute), from_callee: __callee__
6
6
  end
7
7
 
8
8
  def money_field_edit(object, attribute)
@@ -3,7 +3,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:month_select]=:integer
3
3
 
4
4
  # date
5
5
  def month_select_show(object, attribute)
6
- link_to_inline_edit object, attribute, (1..12).include?(object[attribute]) ? I18n.localize(Date.new(1970,object[attribute],1), :format => '%B') : "<i class='fi-plus'></i>".html_safe
6
+ link_to_inline_edit object, attribute, (1..12).include?(object[attribute]) ? I18n.localize(Date.new(1970,object[attribute],1), :format => '%B') : "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
7
7
  end
8
8
 
9
9
  def month_select_edit(object, attribute)
@@ -3,7 +3,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:month_year_picker]=:date
3
3
 
4
4
  # date
5
5
  def month_year_picker_show(object, attribute)
6
- link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).strftime("%B %Y")
6
+ link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).strftime("%B %Y"), from_callee: __callee__
7
7
  end
8
8
 
9
9
  def month_year_picker_edit(object, attribute)
@@ -2,7 +2,7 @@
2
2
  #InlineForms::SPECIAL_COLUMN_TYPES[:text_field]=:string
3
3
 
4
4
  def move_show(object, attribute)
5
- link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe
5
+ link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
6
6
  end
7
7
 
8
8
  def move_edit(object, attribute)
@@ -11,7 +11,7 @@ def multi_image_field_show(object, attribute)
11
11
  msg = image_tag(o.send(:url))
12
12
  end
13
13
  end
14
- link_to_inline_edit object, attribute, msg
14
+ link_to_inline_edit object, attribute, msg, from_callee: __callee__
15
15
  end
16
16
 
17
17
  def multi_image_field_edit(object, attribute)
@@ -2,7 +2,7 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:plain_text_area]=:text
3
3
 
4
4
  def plain_text_area_show(object, attribute)
5
- link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute]
5
+ link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
6
6
  end
7
7
 
8
8
  def plain_text_area_edit(object, attribute)
@@ -4,10 +4,10 @@
4
4
  # checklist
5
5
  def question_list_show(object, attribute)
6
6
  out = '<ul class="question_list">'
7
- out << link_to_inline_edit(object, attribute) if object.send(attribute).empty?
7
+ out << link_to_inline_edit(object, attribute, from_callee: __callee__) if object.send(attribute).empty?
8
8
  object.send(attribute).sort.each do | item |
9
9
  out << '<li>'
10
- out << link_to_inline_edit(object, attribute, item._presentation )
10
+ out << link_to_inline_edit(object, attribute, item._presentation, from_callee: __callee__ )
11
11
  out << '</li>'
12
12
  end
13
13
  out << '</ul>'
@@ -6,7 +6,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:radio_button]=:integer
6
6
 
7
7
  def radio_button_show(object, attribute)
8
8
  values = attribute_values(object, attribute)
9
- link_to_inline_edit object, attribute, object.send(attribute) ? values.assoc(object.send(attribute))[1] : ""
9
+ link_to_inline_edit object, attribute, object.send(attribute) ? values.assoc(object.send(attribute))[1] : "", from_callee: __callee__
10
10
  end
11
11
 
12
12
  def radio_button_edit(object, attribute)
@@ -8,7 +8,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:scale_with_integers]=:integer
8
8
  #
9
9
  def scale_with_integers_show(object, attribute)
10
10
  values = attribute_values(object, attribute)
11
- link_to_inline_edit object, attribute, values[object.send(attribute).to_s]
11
+ link_to_inline_edit object, attribute, values[object.send(attribute).to_s], from_callee: __callee__
12
12
  end
13
13
 
14
14
  def scale_with_integers_edit(object, attribute)
@@ -7,7 +7,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:scale_with_values]=:integer
7
7
  # values must be a hash { integer => string, ... } or an one-dimensional array of strings
8
8
  def scale_with_values_show(object, attribute)
9
9
  values = attribute_values(object, attribute)
10
- link_to_inline_edit object, attribute, values[object.send(attribute)][1]
10
+ link_to_inline_edit object, attribute, values[object.send(attribute)][1], from_callee: __callee__
11
11
  end
12
12
 
13
13
  def scale_with_values_edit(object, attribute)
@@ -9,7 +9,7 @@ def simple_file_field_show(object, attribute)
9
9
  model = object.class.to_s.pluralize.underscore
10
10
  link_to filename, "/#{model}/#{method}/#{object.id}" # route must exist!!
11
11
  else
12
- link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe
12
+ link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
13
13
  end
14
14
  end
15
15
 
@@ -31,7 +31,7 @@ def slider_with_values_show(object, attribute)
31
31
  });
32
32
  </script>').html_safe
33
33
  end
34
- link_to_inline_edit object, attribute, out
34
+ link_to_inline_edit object, attribute, out, from_callee: __callee__
35
35
  end
36
36
 
37
37
  def slider_with_values_edit(object, attribute)
@@ -3,7 +3,7 @@ InlineForms::SPECIAL_COLUMN_TYPES[:text_area]=:text
3
3
 
4
4
  def text_area_show(object, attribute)
5
5
  if object.send(attribute).blank?
6
- link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe
6
+ link_to_inline_edit object, attribute, "<i class='fi-plus'></i>".html_safe, from_callee: __callee__
7
7
  else
8
8
  if defined? Ckeditor
9
9
  link_to_inline_edit object,
@@ -25,9 +25,10 @@ def text_area_show(object, attribute)
25
25
  :class => "glass_plate",
26
26
  :title => '' ) +
27
27
  "<script>delete CKEDITOR.instances['textarea_#{object.class.name.underscore}_#{object.id}_#{attribute.to_s}']</script>".html_safe +
28
- '</div>'.html_safe
28
+ '</div>'.html_safe,
29
+ from_callee: __callee__
29
30
  else
30
- link_to_inline_edit object, attribute, object[attribute]
31
+ link_to_inline_edit object, attribute, object[attribute], from_callee: __callee__
31
32
  end
32
33
  end
33
34
  end
@@ -2,7 +2,7 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:text_area_without_ckeditor]=:text
3
3
 
4
4
  def text_area_without_ckeditor_show(object, attribute)
5
- link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute]
5
+ link_to_inline_edit object, attribute, (object[attribute].nil? || object[attribute].empty?) ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
6
6
  end
7
7
 
8
8
  def text_area_without_ckeditor_edit(object, attribute)
@@ -2,7 +2,7 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:text_field]=:string
3
3
 
4
4
  def text_field_show(object, attribute)
5
- link_to_inline_edit object, attribute, object[attribute].blank? ? "<i class='fi-plus'></i>".html_safe : object[attribute]
5
+ link_to_inline_edit object, attribute, object[attribute].blank? ? "<i class='fi-plus'></i>".html_safe : object[attribute], from_callee: __callee__
6
6
  end
7
7
 
8
8
  def text_field_edit(object, attribute)
@@ -3,7 +3,7 @@
3
3
 
4
4
  # time
5
5
  def time_select_show(object, attribute)
6
- link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).to_datetime.strftime("%l:%M%P")
6
+ link_to_inline_edit object, attribute, object.send(attribute).nil? ? "<i class='fi-plus'></i>".html_safe : object.send(attribute).to_datetime.strftime("%l:%M%P"), from_callee: __callee__
7
7
  end
8
8
 
9
9
  def time_select_edit(object, attribute)
@@ -21,10 +21,10 @@ module InlineFormsHelper
21
21
  # close link
22
22
  def close_link( object, update_span, html_class = 'button close_button' )
23
23
  link_to "<i class='fi-x'></i>".html_safe,
24
- send( object.class.to_s.underscore + '_path',
25
- object,
26
- :update => update_span,
27
- :close => true ),
24
+ polymorphic_path(
25
+ object,
26
+ :update => update_span,
27
+ :close => true ),
28
28
  :remote => true,
29
29
  :class => html_class,
30
30
  :title => t('inline_forms.view.close')
@@ -60,9 +60,9 @@ module InlineFormsHelper
60
60
  hard=''
61
61
  if cancan_disabled? || ( can? :destroy, object )
62
62
  hard = link_to "&nbsp;&nbsp;<font color='FF0000'><i class='fi-x'></i></font>".html_safe,
63
- send( object.class.to_s.underscore + '_path',
64
- object,
65
- :update => update_span ),
63
+ polymorphic_path(
64
+ object,
65
+ :update => update_span ),
66
66
  :method => :delete,
67
67
  :remote => true,
68
68
  :title => t('inline_forms.view.trash')
@@ -127,7 +127,10 @@ module InlineFormsHelper
127
127
  end
128
128
 
129
129
  # link_to_inline_edit
130
- def link_to_inline_edit(object, attribute, attribute_value='', form_element=nil)
130
+ #
131
+ # Pass +from_callee:+ +__callee__+ from the enclosing +*_show+ method so the edit route receives the correct form element name.
132
+ def link_to_inline_edit(object, attribute, attribute_value='', from_callee:)
133
+ form_element = InlineForms.form_element_string_from_callee(from_callee)
131
134
  attribute_value = attribute_value.to_s
132
135
  spaces = attribute_value.length > 40 ? 0 : 40 - attribute_value.length
133
136
  value = h(attribute_value) + ("&nbsp;" * spaces).html_safe
@@ -135,11 +138,11 @@ module InlineFormsHelper
135
138
  if (cancan_disabled? rescue true) || ( can? :update, object, attribute )
136
139
  # some problem with concerns makes this function not available when called direct. FIXME
137
140
  link_to value,
138
- send( 'edit_' + object.class.to_s.underscore + '_path',
139
- object,
140
- :attribute => attribute.to_s,
141
- :form_element => form_element.nil? ? calling_method.sub(/_[a-z]+$/,'').sub(/block in /,'') : form_element,
142
- :update => css_class_id ),
141
+ edit_polymorphic_path(
142
+ object,
143
+ :attribute => attribute.to_s,
144
+ :form_element => form_element,
145
+ :update => css_class_id ),
143
146
  :remote => true
144
147
  else
145
148
  h(attribute_value)
@@ -223,19 +226,3 @@ module InlineFormsHelper
223
226
  end
224
227
 
225
228
  end
226
-
227
- module Kernel
228
- private
229
- # make the current method available
230
- # http://www.ruby-forum.com/topic/75258
231
- # supposedly, this is fixed in 1.9
232
- def this_method
233
- caller[0] =~ /`([^']*)'/ and $1
234
- end
235
- # make the calling method available
236
- # http://www.ruby-forum.com/topic/75258
237
- # supposedly, this is fixed in 1.9
238
- def calling_method
239
- caller[1] =~ /`([^']*)'/ and $1
240
- end
241
- end
@@ -4,10 +4,10 @@
4
4
  <%= link_to_destroy(@object, @update_span) -%>
5
5
  </div>
6
6
  <div class="small-11 column">
7
- <%= link_to h(@object._presentation), send(@object.class.to_s.underscore + "_path", @object, :update => @update_span), :remote => true -%>
7
+ <%= link_to h(@object._presentation), polymorphic_path(@object, :update => @update_span), :remote => true -%>
8
8
  </div>
9
9
  <% else %>
10
10
  <div class="small-12 column">
11
- <%= link_to h(@object._presentation), send(@object.class.to_s.underscore + "_path", @object, :update => @update_span), :remote => true -%>
11
+ <%= link_to h(@object._presentation), polymorphic_path(@object, :update => @update_span), :remote => true -%>
12
12
  </div>
13
13
  <% end %>
@@ -1,5 +1,6 @@
1
1
  <% @BUTTONS_UNDER = [ "text_area", "kansen_slider" ] %>
2
- <%= form_tag send(@object.class.to_s.underscore + '_path', :update => @update_span,
2
+ <%= form_tag polymorphic_path(@object,
3
+ :update => @update_span,
3
4
  :attribute => @attribute,
4
5
  :form_element => @form_element,
5
6
  :sub_id => @sub_id ),
@@ -42,7 +43,7 @@
42
43
  <%= submit_tag "ok", :class => "postfix button"-%>
43
44
  </div>
44
45
  <div class="small-2 columns">
45
- <%= link_to( send( @object.class.to_s.underscore + '_path', :update => @update_span || "field_#{@attribute}_#{@object.id.to_s}",
46
+ <%= link_to( polymorphic_path( @object, :update => @update_span || "field_#{@attribute}_#{@object.id.to_s}",
46
47
  :attribute => @attribute,
47
48
  :form_element => @form_element,
48
49
  :sub_id => @sub_id ),
@@ -61,7 +62,7 @@
61
62
  <%= submit_tag "ok", :class => "postfix button"-%>
62
63
  </div>
63
64
  <div class="small-2 columns">
64
- <%= link_to( send( @object.class.to_s.underscore + '_path', :update => @update_span || "field_#{@attribute}_#{@object.id.to_s}",
65
+ <%= link_to( polymorphic_path( @object, :update => @update_span || "field_#{@attribute}_#{@object.id.to_s}",
65
66
  :attribute => @attribute,
66
67
  :form_element => @form_element,
67
68
  :sub_id => @sub_id ),
@@ -25,7 +25,7 @@
25
25
  </div>
26
26
  </div>
27
27
 
28
- <%= form_tag send(@Klass.to_s.underscore.pluralize + '_path', :update => @update_span,
28
+ <%= form_tag polymorphic_path(@Klass, :update => @update_span,
29
29
  :parent_class => @parent_class,
30
30
  :parent_id => @parent_id ),
31
31
  :multipart => true, :remote => true, :class => "edit_form" do -%>
@@ -56,7 +56,7 @@
56
56
  &nbsp;
57
57
  </div>
58
58
  <div class='small-11 column' >
59
- <%= link_to( send(@Klass.to_s.underscore.pluralize + '_path', :update => @update_span,
59
+ <%= link_to( polymorphic_path(@Klass, :update => @update_span,
60
60
  :parent_class => @parent_class,
61
61
  :parent_id => @parent_id,
62
62
  :ul_needed => true ),