wobapphelpers 3.1.1 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5af48b4d13534d6728ad14474163cbd02cda0b6e
4
- data.tar.gz: 51f77953886d1a0e800b3101836a05529aeb1881
2
+ SHA256:
3
+ metadata.gz: 12c301fa73d2bc6e7ed490e0c4705e97fe958cecadab3cd603bb00c6bc9f43e0
4
+ data.tar.gz: b2c5d81eb33f8f8cca05c2a51e5c835394db40a31f04304ecb4db9a0ac8712c8
5
5
  SHA512:
6
- metadata.gz: c742fc336988cf36311a1c434192acd4c6f9b4c8f62655772510439cbcdf150151e0a6032fac018b226724ccbd1182305fd87a8a068776756026a6090adee142
7
- data.tar.gz: 89077a16afca966a5229b4baffb209077c5f2107dc46bf87ddf1ccc9e0f15ffce33fa31a43df6919dd23f366b0317948fdd2ba01985e9066eb9283f94827b74a
6
+ metadata.gz: 5761d19b7170a14b1e870b938773dedc4eae005ff3a4be9d59f90e85c1d5b15263319b9b8610ac6035ed43aeb85f034ba00de04f335f093a6e433c45ef8950eb
7
+ data.tar.gz: d3799fb2cb12d6706491f8e1e323bdb762f4f891201d65fe3c3a587a175b922a95769a7d4b6cc4a13f61122126a9171dadaf10d418d1503c1c83f0d1fd2e97f0
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2018 Wolfgang Barth
3
+ Copyright (c) 2014-2019 Wolfgang Barth
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,16 +1,22 @@
1
1
  wobapphelpers
2
2
  =============
3
3
 
4
- Rails helpers and more shared between common wob rails applications. Depends on twitter bootstrap.
4
+ This is the ''master'' branch, for use with rails >= 5.2.
5
+
6
+ BREAKING CHANGE between 3-0 -> master: please reinstall wobapphelpers locales with:
7
+
8
+ * rails g wobapphelpers:install
5
9
 
6
- This is the ''master'' branch, for use with rails 5.1.
10
+
11
+ Rails helpers and more shared between common wob rails applications. Depends on twitter bootstrap.
7
12
 
8
13
  Requirements
9
14
  ------------
10
15
 
11
16
  | branch | rails | ruby | bootstrap | icons |
12
17
  |------------|-------|--------|-----------|-------------|
13
- | master | 5.1 | >= 2.3 | v4 | fontawesome |
18
+ | master | 5.2 | >= 2.3 | v4 | fontawesome |
19
+ | 3-0-stable | 5.1 | >= 2.3 | v4 | fontawesome |
14
20
  | 2-0-stable | 5.0 | >= 2.2 | v3 | glyphicons |
15
21
  | 1-0-stable | 4.2 | >= 2.0 | v3 | glyphicons |
16
22
 
@@ -149,7 +155,7 @@ other variable names you have to use :add_breadcrumbs_for, i.e.
149
155
  Licence
150
156
  -------
151
157
 
152
- Wobapphelpers Copyright (C) 2014-2018 Wolfgang Barth
158
+ Wobapphelpers Copyright (C) 2014-2019 Wolfgang Barth
153
159
 
154
160
  MIT License, see [LICENSE](LICENSE)
155
161
 
@@ -0,0 +1,3 @@
1
+ //= link_tree ../images
2
+ //= link_directory ../javascripts .js
3
+ //= link_directory ../stylesheets .css
@@ -1,9 +1,14 @@
1
1
  de:
2
2
  wobapphelpers:
3
3
  helpers:
4
- back: "Zurück"
5
- cancel: "Abbrechen"
6
- controller:
7
- new: "%{name} erstellen"
8
- edit: "%{name} bearbeiten"
9
- update: "%{name} bearbeiten"
4
+ back: Zurück
5
+ cancel: Abbrechen
6
+ actions:
7
+ new: "%{model} erstellen"
8
+ create: "%{model} erstellen"
9
+ show: "%{model} anzeigen"
10
+ edit: "%{model} bearbeiten"
11
+ copy: "%{model} kopieren"
12
+ update: "%{model} bearbeiten"
13
+ destroy: "%{model} löschen"
14
+ destroy_confirm: "Der Datensatz kann nicht wieder hergestellt werden!"
@@ -3,7 +3,12 @@ en:
3
3
  helpers:
4
4
  back: Back
5
5
  cancel: Cancel
6
- controller:
7
- new: "create %{name}"
8
- edit: "update %{name}"
9
- update: "update %{name}"
6
+ actions:
7
+ new: "create %{model}"
8
+ create: "create %{model}"
9
+ show: "show %{model}"
10
+ edit: "update %{model}"
11
+ update: "update %{model}"
12
+ copy: "copy %{model}"
13
+ destroy: "destroy %{model}"
14
+ destroy_confirm: "record would be finally destroyed, no recovery possible!"
@@ -3,11 +3,6 @@ module Wobapphelpers
3
3
  module ActionController
4
4
  def add_breadcrumb(name, url)
5
5
  breadcrumbs ||= (session[:breadcrumbs] || [] )
6
- if params[:bci]
7
- # this a back link of an existing breadcrumb entry,
8
- # shorten the list
9
- breadcrumbs = breadcrumbs.first(params[:bci].to_i)
10
- end
11
6
  if breadcrumbs.size == 0 || url != breadcrumbs.last[1]
12
7
  breadcrumbs << [name, url]
13
8
  end
@@ -5,21 +5,16 @@ module Wobapphelpers
5
5
  return if Wobapphelpers.breadcrumb_controller_blacklist.include?(controller.controller_path)
6
6
  return if session[:breadcrumbs].nil? || session[:breadcrumbs].size == 0
7
7
  track = ""
8
- session[:breadcrumbs].each_with_index do |b, idx|
9
- track += "&gt; #{breadcrumb_idx(b[0], b[1], idx)} "
8
+ session[:breadcrumbs].each do |b|
9
+ track += "&gt; #{set_breadcrumb(b[0], b[1])} "
10
10
  end
11
11
  %Q[<div id="breadcrumbs" class="visible-desktop">#{track}</div>].html_safe
12
12
  end
13
13
 
14
- def breadcrumb_idx(name, url, idx, html_class=nil)
14
+ def set_breadcrumb(name, url, options = {})
15
+ options.symbolize_keys!
15
16
  uri = URI.parse(url)
16
- query = uri.query || ""
17
- if query =~ /bci=(\d+)/
18
- uri.query.gsub!(/bci=(\d+)/, "bci=#{idx}")
19
- else
20
- uri.query = query + "&bci=#{idx}"
21
- end
22
- link_to name, uri.to_s.gsub('?&','?'), :class => html_class
17
+ link_to name, uri.to_s, options
23
18
  end
24
19
  end
25
20
  end
@@ -19,11 +19,9 @@ module Wobapphelpers
19
19
  mypoly, obj = get_parts(poly)
20
20
  if _can?(:create, obj)
21
21
  options.symbolize_keys!
22
- link_to obj.model_name.human + " erstellen",
23
- new_polymorphic_path(mypoly),
24
- remote: options.fetch(:remote, false),
25
- title: options.fetch(:title, title(obj) + " hinzufügen"),
26
- class: options.fetch(:class, 'btn btn-secondary')
22
+ link_to title(obj, :new),
23
+ new_polymorphic_path(mypoly),
24
+ default_options(obj, :new).merge(options)
27
25
  end
28
26
  end
29
27
 
@@ -31,10 +29,8 @@ module Wobapphelpers
31
29
  mypoly, obj = get_parts(poly)
32
30
  if _can?(:read, obj)
33
31
  options.symbolize_keys!
34
- link_to icon_show, polymorphic_path(mypoly),
35
- remote: options.fetch(:remote, false),
36
- title: options.fetch(:title, title(obj) + " anzeigen"),
37
- class: options.fetch(:class, 'btn btn-secondary')
32
+ link_to icon_show, polymorphic_path(mypoly),
33
+ default_options(obj, :show).merge(options)
38
34
  end
39
35
  end
40
36
 
@@ -42,10 +38,8 @@ module Wobapphelpers
42
38
  mypoly, obj = get_parts(poly)
43
39
  if _can?(:edit, obj)
44
40
  options.symbolize_keys!
45
- link_to icon_edit, edit_polymorphic_path(mypoly),
46
- remote: options.fetch(:remote, false),
47
- title: options.fetch(:title, title(obj) + " bearbeiten"),
48
- class: options.fetch(:class, 'btn btn-secondary')
41
+ link_to icon_edit, edit_polymorphic_path(mypoly),
42
+ default_options(obj, :edit).merge(options)
49
43
  end
50
44
  end
51
45
 
@@ -53,15 +47,11 @@ module Wobapphelpers
53
47
  mypoly, obj = get_parts(poly)
54
48
  if _can?(:destroy, obj)
55
49
  options.symbolize_keys!
56
- verify = options.has_key?(:verify) ? { verify: options.fetch(:verify) } : {}
57
- link_to icon_delete, mypoly,
58
- remote: options.fetch(:remote, false),
59
- data: {
60
- confirm: options.fetch(:confirm, "Sie wollen das Objekt löschen.\nSind Sie sicher?")
61
- }.merge(verify),
62
- method: :delete,
63
- title: options.fetch(:title, title(obj) + " löschen"),
64
- class: options.fetch(:class, 'btn btn-danger')
50
+ options = delete_options(obj).merge(options)
51
+ if options[:data][:confirm].blank?
52
+ options[:data][:confirm] = confirm_message(obj)
53
+ end
54
+ link_to icon_delete, mypoly, options
65
55
  end
66
56
  end
67
57
 
@@ -76,7 +66,7 @@ module Wobapphelpers
76
66
  idx = session[:breadcrumbs].size - 2
77
67
  title = bc[0]
78
68
  goto = bc[1]
79
- breadcrumb_idx(label, goto, idx, 'btn btn-secondary')
69
+ set_breadcrumb(label, goto, class: 'btn btn-secondary')
80
70
  else
81
71
  link_to label, url_for(:back), :class => 'btn btn-secondary'
82
72
  end
@@ -134,13 +124,14 @@ module Wobapphelpers
134
124
  end
135
125
  end
136
126
 
137
- def title(obj)
127
+ def title(obj, action)
138
128
  if obj.kind_of? Class
139
129
  model = obj
140
130
  else
141
131
  model = obj.class
142
132
  end
143
- t('activerecord.models.' + model.model_name.i18n_key.to_s)
133
+ t(action.to_s, scope: "wobapphelpers.actions".to_sym,
134
+ model: t('activerecord.models.' + model.model_name.i18n_key.to_s))
144
135
  end
145
136
 
146
137
  def controlleraction
@@ -148,8 +139,8 @@ module Wobapphelpers
148
139
  namespace = controller.controller_path
149
140
  resource_name = t("activerecord.models.#{namespace.singularize}")
150
141
  search_for = [namespace, action].join(".").to_sym
151
- t(search_for, scope: "wobapphelpers.controller".to_sym,
152
- default: action.to_sym, name: resource_name)
142
+ t(search_for, scope: "wobapphelpers.actions".to_sym,
143
+ default: action.to_sym, model: resource_name)
153
144
  end
154
145
 
155
146
  def _can?(action, obj)
@@ -165,6 +156,28 @@ module Wobapphelpers
165
156
  model
166
157
  end
167
158
  end
159
+
160
+ def default_options(obj, action)
161
+ {
162
+ title: title(obj, action),
163
+ remote: false,
164
+ class: 'btn btn-secondary',
165
+ }
166
+ end
167
+
168
+ def delete_options(obj)
169
+ {
170
+ title: title(obj, :destroy),
171
+ remote: false,
172
+ class: 'btn btn-danger',
173
+ data: {},
174
+ method: :delete,
175
+ }
176
+ end
177
+
178
+ def confirm_message(obj)
179
+ "#{title(obj, :destroy)}?\n" + t('wobapphelpers.actions.destroy_confirm')
180
+ end
168
181
  end
169
182
  end
170
183
  end
@@ -11,7 +11,7 @@ module Wobapphelpers
11
11
  delete: 'trash',
12
12
  document: 'file',
13
13
  download: 'download',
14
- edit: 'pencil',
14
+ edit: 'pencil-alt',
15
15
  help: 'question',
16
16
  info: 'info',
17
17
  left: 'arrow-left',
@@ -26,7 +26,7 @@ module Wobapphelpers
26
26
  }
27
27
 
28
28
  def icon(what)
29
- raw(%Q[<i class="fa fa-#{what} fa-fw" aria-hidden="true"></i>])
29
+ raw(%Q[<i class="fas fa-#{what} fa-fw" aria-hidden="true"></i>])
30
30
  end
31
31
 
32
32
  PREDEFINED_ICONS.each do |key,value|
@@ -1,4 +1,4 @@
1
1
  module Wobapphelpers
2
- VERSION = "3.1.1".freeze
3
- RELEASEDATE = "2018-07-27".freeze
2
+ VERSION = "4.0.0".freeze
3
+ RELEASEDATE = "2019-11-28".freeze
4
4
  end
@@ -10,8 +10,8 @@ class BreadcrumbHelperHelperTest < ActionDispatch::IntegrationTest
10
10
  get home_path
11
11
  get posts_path
12
12
  assert_select "div#breadcrumbs" do
13
- assert_select "[href='/home?bci=0']", title: "Home"
14
- assert_select "[href='/posts?bci=1']", title: "Postings"
13
+ assert_select "[href='/home']", title: "Home"
14
+ assert_select "[href='/posts']", title: "Postings"
15
15
  end
16
16
  end
17
17
 
@@ -22,7 +22,7 @@ class BreadcrumbHelperHelperTest < ActionDispatch::IntegrationTest
22
22
  get home_path, headers: {'HTTP_REFERER' => 'http://example.org'}
23
23
  get posts_path
24
24
  assert_select "[class=?]", "btn btn-secondary" do
25
- assert_select "[href='/home?bci=2']", text: /.*Zurück/
25
+ assert_select "[href='/home']", text: /.*Zurück/
26
26
  end
27
27
  end
28
28
 
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- require 'sass'
3
2
  require 'jquery-rails'
4
3
  require 'shoulda-context'
5
4
 
@@ -28,12 +27,12 @@ class ActionViewHelperTest < ActionDispatch::IntegrationTest
28
27
  "No back button found"
29
28
  end
30
29
 
31
- should "cancel_button renders i with class fa" do
30
+ should "cancel_button renders i with class fas" do
32
31
  visit new_post_path
33
- assert page.has_text?('Post/new')
32
+ assert page.has_text?('Posting erstellen')
34
33
  within('form') do
35
34
  assert page.has_link?('Abbrechen'), "button submit not found"
36
- assert find('a.btn.btn-secondary i.fa.fa-trash'),
35
+ assert find('a.btn.btn-secondary i.fas.fa-trash'),
37
36
  "button cancel not found"
38
37
  end
39
38
  end
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- require 'sass'
3
2
  require 'jquery-rails'
4
3
  require 'shoulda-context'
5
4
 
@@ -12,7 +12,7 @@ class FormLegendTest < ActionController::TestCase
12
12
  get :new
13
13
  assert_select "div.row" do
14
14
  assert_select "div" do
15
- assert_select "legend", text: "Post/new"
15
+ assert_select "legend", text: "Posting erstellen"
16
16
  end
17
17
  end
18
18
  end
@@ -21,7 +21,7 @@ class FormLegendTest < ActionController::TestCase
21
21
  get :edit, params: { id: @p1 }
22
22
  assert_select "div.row" do
23
23
  assert_select "div" do
24
- assert_select "legend", text: "Post/edit"
24
+ assert_select "legend", text: "Posting bearbeiten"
25
25
  end
26
26
  end
27
27
  end
@@ -1,21 +1,20 @@
1
1
  require 'test_helper'
2
- require 'sass'
3
2
 
4
3
  class IconHelperTest < ActionView::TestCase
5
4
  include Wobapphelpers::Helpers::IconHelper
6
5
 
7
- test "icon() renders i with class fa" do
6
+ test "icon() renders i with class fas" do
8
7
  render plain: icon('search')
9
8
 
10
- assert_select 'i.fa.fa-search.fa-fw', 1
11
- assert_select 'i.fa.fa-quark', 0
9
+ assert_select 'i.fas.fa-search.fa-fw', 1
10
+ assert_select 'i.fas.fa-quark', 0
12
11
  end
13
12
 
14
13
  Wobapphelpers::Helpers::IconHelper::PREDEFINED_ICONS.each do |key,value|
15
14
  test "icon_#{key} renders i with class fa-#{value}" do
16
15
  render plain: send("icon_#{key}")
17
16
 
18
- assert_select "i.fa.fa-#{value}", 1
17
+ assert_select "i.fas.fa-#{value}", 1
19
18
  end
20
19
  end
21
20
  end
@@ -1,5 +1,4 @@
1
1
  require 'test_helper'
2
- require 'sass'
3
2
 
4
3
  class ShowEditDeleteLinkHelperTest < ActionView::TestCase
5
4
  include Wobapphelpers::Helpers::All
@@ -11,7 +11,7 @@ class HelperDeliveryTest < ActionDispatch::IntegrationTest
11
11
  get home_path
12
12
  assert_response :success
13
13
  Wobapphelpers::Helpers::IconHelper::PREDEFINED_ICONS.each do |key,value|
14
- assert_match "<i class=\"fa fa-#{value} fa-fw\" aria-hidden=\"true\"></i>", response.body
14
+ assert_match "<i class=\"fas fa-#{value} fa-fw\" aria-hidden=\"true\"></i>", response.body
15
15
  end
16
16
  end
17
17
 
@@ -0,0 +1,18 @@
1
+ Wobapphelpers.setup do |config|
2
+ #
3
+ # exclude some controllers from breadcrumbs
4
+ # the given string must match controller.controller_name
5
+ #
6
+ # example:
7
+ # config.breadcrumb_controller_blacklist = ["user_sessions"]
8
+ # default:
9
+ # config.breadcrumb_controller_blacklist = []
10
+ #
11
+ # show action links only if has ability to execute the action
12
+ # * :none : always present action links
13
+ # * :cancan1 : for cancancan '~>1.7.0' or cancan '~>1.6.0'
14
+ # * :cancan2 : for cancan '~>2.0.0', untested
15
+ #
16
+ # default:
17
+ # config.cancan = :none
18
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wobapphelpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wolfgang Barth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-27 00:00:00.000000000 Z
11
+ date: 2019-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: responders
14
+ name: sassc-rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -26,32 +26,18 @@ dependencies:
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '5.0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '5.0'
41
- - !ruby/object:Gem::Dependency
42
- name: sassc-rails
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: '0'
33
+ version: '5.0'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: '0'
40
+ version: '5.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: coffee-rails
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +100,20 @@ dependencies:
114
100
  - - "<="
115
101
  - !ruby/object:Gem::Version
116
102
  version: '6'
103
+ - !ruby/object:Gem::Dependency
104
+ name: responders
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
117
  - !ruby/object:Gem::Dependency
118
118
  name: sqlite3
119
119
  requirement: !ruby/object:Gem::Requirement
@@ -292,6 +292,7 @@ files:
292
292
  - LICENSE
293
293
  - README.md
294
294
  - Rakefile
295
+ - app/assets/config/manifest.js
295
296
  - app/assets/stylesheets/wobapphelpers/breadcrumbs.scss
296
297
  - config/locales/de.yml
297
298
  - config/locales/en.yml
@@ -363,7 +364,7 @@ files:
363
364
  - test/integration/helper_delivery_test.rb
364
365
  - test/responders/flash_test.rb
365
366
  - test/test_helper.rb
366
- - test/tmp/lib/templates/rails/scaffold_controller/controller.rb
367
+ - test/tmp/config/initializers/wobapphelpers.rb
367
368
  - test/translate_test.rb
368
369
  - test/wobapphelpers_test.rb
369
370
  homepage: http://github.com/swobspace/wobapphelpers
@@ -385,13 +386,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
386
  - !ruby/object:Gem::Version
386
387
  version: '0'
387
388
  requirements: []
388
- rubyforge_project:
389
- rubygems_version: 2.6.14.1
389
+ rubygems_version: 3.0.3
390
390
  signing_key:
391
391
  specification_version: 4
392
392
  summary: Rails helpers and more shared between wob's rails applications
393
393
  test_files:
394
- - test/tmp/lib/templates/rails/scaffold_controller/controller.rb
394
+ - test/tmp/config/initializers/wobapphelpers.rb
395
395
  - test/wobapphelpers_test.rb
396
396
  - test/helpers/can_view_helper_test.rb
397
397
  - test/helpers/action_view_helper_test.rb
@@ -1,66 +0,0 @@
1
- <% if namespaced? -%>
2
- require_dependency "<%= namespaced_file_path %>/application_controller"
3
-
4
- <% end -%>
5
- <% module_namespacing do -%>
6
- class <%= controller_class_name %>Controller < ApplicationController
7
- before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
8
- before_action :add_breadcrumb_show, only: [:show]
9
-
10
- # GET <%= route_url %>
11
- def index
12
- @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
13
- respond_with(@<%= plural_table_name %>)
14
- end
15
-
16
- # GET <%= route_url %>/1
17
- def show
18
- respond_with(@<%= singular_table_name %>)
19
- end
20
-
21
- # GET <%= route_url %>/new
22
- def new
23
- @<%= singular_table_name %> = <%= orm_class.build(class_name) %>
24
- respond_with(@<%= singular_table_name %>)
25
- end
26
-
27
- # GET <%= route_url %>/1/edit
28
- def edit
29
- end
30
-
31
- # POST <%= route_url %>
32
- def create
33
- @<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
34
-
35
- @<%= orm_instance.save %>
36
- respond_with(@<%= singular_table_name %>)
37
- end
38
-
39
- # PATCH/PUT <%= route_url %>/1
40
- def update
41
- @<%= orm_instance.update("#{singular_table_name}_params") %>
42
- respond_with(@<%= singular_table_name %>)
43
- end
44
-
45
- # DELETE <%= route_url %>/1
46
- def destroy
47
- @<%= orm_instance.destroy %>
48
- respond_with(@<%= singular_table_name %>)
49
- end
50
-
51
- private
52
- # Use callbacks to share common setup or constraints between actions.
53
- def set_<%= singular_table_name %>
54
- @<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
55
- end
56
-
57
- # Only allow a trusted parameter "white list" through.
58
- def <%= "#{singular_table_name}_params" %>
59
- <%- if attributes_names.empty? -%>
60
- params[:<%= singular_table_name %>]
61
- <%- else -%>
62
- params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
63
- <%- end -%>
64
- end
65
- end
66
- <% end -%>