audited_views 0.0.1

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 (126) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +35 -0
  4. data/Rakefile +21 -0
  5. data/app/assets/config/audited_views_manifest.js +0 -0
  6. data/app/helpers/audited_views_helper.rb +115 -0
  7. data/app/models/audit.rb +4 -0
  8. data/app/views/application/_audit_record.html.erb +55 -0
  9. data/app/views/application/_audits.html.erb +7 -0
  10. data/app/views/application/_controls.html.erb +10 -0
  11. data/config/locales/en.yml +19 -0
  12. data/config/locales/pt-BR.yml +19 -0
  13. data/config/routes.rb +3 -0
  14. data/lib/audited_views.rb +5 -0
  15. data/lib/audited_views/engine.rb +4 -0
  16. data/lib/audited_views/version.rb +3 -0
  17. data/lib/tasks/audited_views_tasks.rake +4 -0
  18. data/spec/dummy/Rakefile +6 -0
  19. data/spec/dummy/app/assets/config/manifest.js +4 -0
  20. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  21. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  22. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  23. data/spec/dummy/app/channels/application_cable/channel.rb +4 -0
  24. data/spec/dummy/app/channels/application_cable/connection.rb +4 -0
  25. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  26. data/spec/dummy/app/controllers/products_controller.rb +58 -0
  27. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  28. data/spec/dummy/app/helpers/products_helper.rb +2 -0
  29. data/spec/dummy/app/jobs/application_job.rb +2 -0
  30. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  31. data/spec/dummy/app/models/application_record.rb +3 -0
  32. data/spec/dummy/app/models/product.rb +3 -0
  33. data/spec/dummy/app/models/user.rb +6 -0
  34. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  36. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  37. data/spec/dummy/app/views/products/_form.html.erb +42 -0
  38. data/spec/dummy/app/views/products/edit.html.erb +6 -0
  39. data/spec/dummy/app/views/products/index.html.erb +35 -0
  40. data/spec/dummy/app/views/products/new.html.erb +5 -0
  41. data/spec/dummy/app/views/products/show.html.erb +31 -0
  42. data/spec/dummy/bin/bundle +3 -0
  43. data/spec/dummy/bin/rails +4 -0
  44. data/spec/dummy/bin/rake +4 -0
  45. data/spec/dummy/bin/setup +38 -0
  46. data/spec/dummy/bin/update +29 -0
  47. data/spec/dummy/bin/yarn +11 -0
  48. data/spec/dummy/config.ru +5 -0
  49. data/spec/dummy/config/application.rb +18 -0
  50. data/spec/dummy/config/boot.rb +5 -0
  51. data/spec/dummy/config/cable.yml +10 -0
  52. data/spec/dummy/config/database.yml +25 -0
  53. data/spec/dummy/config/environment.rb +5 -0
  54. data/spec/dummy/config/environments/development.rb +54 -0
  55. data/spec/dummy/config/environments/production.rb +91 -0
  56. data/spec/dummy/config/environments/test.rb +42 -0
  57. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  58. data/spec/dummy/config/initializers/assets.rb +14 -0
  59. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  60. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  61. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  62. data/spec/dummy/config/initializers/inflections.rb +16 -0
  63. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  64. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/spec/dummy/config/locales/en.yml +33 -0
  66. data/spec/dummy/config/puma.rb +56 -0
  67. data/spec/dummy/config/routes.rb +3 -0
  68. data/spec/dummy/config/secrets.yml +32 -0
  69. data/spec/dummy/config/spring.rb +6 -0
  70. data/spec/dummy/db/development.sqlite3 +0 -0
  71. data/spec/dummy/db/migrate/20170507023018_create_products.rb +13 -0
  72. data/spec/dummy/db/migrate/20170507023113_create_users.rb +10 -0
  73. data/spec/dummy/db/migrate/20170507191539_install_audited.rb +30 -0
  74. data/spec/dummy/db/schema.rb +54 -0
  75. data/spec/dummy/db/test.sqlite3 +0 -0
  76. data/spec/dummy/log/development.log +154 -0
  77. data/spec/dummy/log/test.log +747 -0
  78. data/spec/dummy/package.json +5 -0
  79. data/spec/dummy/public/404.html +67 -0
  80. data/spec/dummy/public/422.html +67 -0
  81. data/spec/dummy/public/500.html +66 -0
  82. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  83. data/spec/dummy/public/apple-touch-icon.png +0 -0
  84. data/spec/dummy/public/favicon.ico +0 -0
  85. data/spec/dummy/spec/factories/products.rb +9 -0
  86. data/spec/dummy/spec/factories/users.rb +6 -0
  87. data/spec/dummy/spec/features/controls_spec.rb +28 -0
  88. data/spec/dummy/spec/helpers/audited_views_helper_spec.rb +8 -0
  89. data/spec/dummy/spec/models/product_spec.rb +4 -0
  90. data/spec/dummy/spec/models/user_spec.rb +4 -0
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-s/-sApyz8RREntIAnO7uawATjXPT2wvPX8w1wQF1XFuSs.cache +1 -0
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3P/3PK7aqnTybA5wVtn4700SPNvcK6dejPg9tiLgBYBViI.cache +2 -0
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3Y/3YWAsbouC_92KRyVIfCR1XZUL6aU5fDhsrDPZPwqLaw.cache +0 -0
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/70/70uPUtQT3y75FopbmEz3gd0jRFdPBXxoGs6V_FqlbX0.cache +1 -0
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9m/9m1uMOh0tNA4F013e0lQ55KsZ1mW9-DJ-P7YQ8ehjO8.cache +1 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Al/AlF65aLeuD-x6AxoO6n4G93XaQ5Nx0MU1FzfD4L3cPc.cache +0 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/D0/D0cNdcvMptZ90AYLZ73Y5d3iFojSVkzXX1hn78q5VSU.cache +0 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/G3/G3-tv19JISLSSRsGC9RGYPFoKz-eJUiLX305MLBRy2I.cache +0 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/HC/HCDOUd7-S45aJ_PjVAC_Vmjyud3i1aQv4cE3t9_Z3Dw.cache +2 -0
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Hb/HbwMdgucEk--be2EHuRlKDWcL3k-dzQfMgpOy60OrTc.cache +1 -0
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/L2/L2y0YEwaUri6z1liCIMCGL4QjIm0SRdCy-uQ95Na6a8.cache +1 -0
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Nl/NlsP11HhLUppMbrveWN9hUdmj5EeypXs_8VJoP7EHCQ.cache +1 -0
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OU/OUrRymFy2GqVPmy2wEwtOU35eAGKpRc9Yd2s6FLH9IA.cache +1 -0
  104. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/PH/PHbdEchD5mfuw2iJHZ14bwbA5umhLrM_H7vcEPsnFBU.cache +1 -0
  105. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Q-/Q-UOgOa_LL2DWgrt0rM8RVF3jeARORAKZzpo9HQJDS4.cache +1 -0
  106. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VO/VOse1hbRPubC1r_WKyZVcYG1tsb06PRsqYBTWSZ_4LQ.cache +0 -0
  107. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Vu/VuoeZYDVkOHSjfAnQhegAaddC_cmOg0_2-fEjwByr2g.cache +1 -0
  108. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WP/WPx0xeq-DpjAUB8Fr6PqvzYSp13C5EpZuuIVQiIfSR8.cache +1 -0
  109. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YJ/YJtvP__n_ITqVJFjg7SNmEV8X5LbGOz153KZHMn7A9I.cache +2 -0
  110. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/b_/b_Itlk9QZZd7Rvf8kcA4yLP1R5Acu7jB-m1xQiSU0qE.cache +2 -0
  111. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bw/bwdvZFbg53AKcjymQ40V9gm6Lk-G_xPEv3mFu5uRSnU.cache +3 -0
  112. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/eS/eS5Narq3MfOC-cyHoerhLMXKH4mVuSCuCUGlUBrsW-g.cache +1 -0
  113. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/g9/g971Klk7lTPw1fRk9VTAKO2DhIDmOMMDyij3ztCQjy8.cache +1 -0
  114. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mX/mX1nlsL_SWOB4y22W5FheRX0YEONKyOY7xUeIvRiHco.cache +2 -0
  115. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/n_/n_xYqQYhwEMQknb3jFQnjlxxBE9TzMNHCdJ-bEyZFIw.cache +2 -0
  116. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nx/nxTv3sKVUQZADJyM3dPaVmUA78MIsMLD_K279yN_GsI.cache +2 -0
  117. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pn/pneR-xUFEeqlsU0chMbmmftc6gAsfjtjN5OaIGlKhRI.cache +0 -0
  118. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ru/ru-jaKyvWi9mo2jrTCMYECWtSm8wxxLH-UKNKEu2Uyk.cache +1 -0
  119. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sE/sE5I8LMVqjxu0PHdY_io7wdnYvUQnL-YQaUIk8sw-M4.cache +0 -0
  120. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v4/v4RHC934V-T5x1Nb2COYpgO8T9xMJDHUEL6q0crUZng.cache +1 -0
  121. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/vV/vVAUGE3VA_1WPwDbZuHjuALjKVuSK8gJL3QGkUCz6us.cache +1 -0
  122. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xl/xlD5Hio6dGiAlbF6RQJSD2DLDNetsbjWSo1ENNi0jdA.cache +1 -0
  123. data/spec/dummy/tmp/capybara/capybara-201705072202363033472193.html +139 -0
  124. data/spec/dummy/tmp/capybara/capybara-201705072204557673614766.html +139 -0
  125. data/spec/spec_helper.rb +20 -0
  126. metadata +374 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 47781b975820493b0c4183ebc83d5ec10d30dc63
4
+ data.tar.gz: 1a59ba2b3821cdae2a457128c9629efa4bb177e6
5
+ SHA512:
6
+ metadata.gz: 7c816f7826c69b8807963ef74dbf3faadb82223304e53ef11b8d111cf184677b584cfc192d2312c384c597e355fbc60570dc766a7f2bc8b62af42589011bb137
7
+ data.tar.gz: 426bf4f2d3d3f5800788669ee3f1612b1b2492cb49e44026405d197a3e8bee1a33690369a04b0d50a7e1df59982fe6b2a1d1ee76d7876b1b3a76dffb973582b3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Douglas Lise
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # AuditedViews
2
+ Views to show change logs collected by audited gem.
3
+
4
+ ## Usage
5
+ Add this to your `show` views:
6
+ ```
7
+ <%= audited_controls(@product) %>
8
+ ```
9
+ And this to your `index` views:
10
+ ```
11
+ <%= audited_controls(@products) %>
12
+ ```
13
+
14
+ ## Installation
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'audited_views'
19
+ ```
20
+
21
+ And then execute:
22
+ ```bash
23
+ $ bundle
24
+ ```
25
+
26
+ Or install it yourself as:
27
+ ```bash
28
+ $ gem install audited_views
29
+ ```
30
+
31
+ ## Contributing
32
+ Contribution directions go here.
33
+
34
+ ## License
35
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
9
+ load 'rails/tasks/engine.rake'
10
+
11
+ Bundler::GemHelper.install_tasks
12
+
13
+ Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
14
+
15
+ require 'rspec/core'
16
+ require 'rspec/core/rake_task'
17
+
18
+ desc "Run all specs in spec directory (excluding plugin specs)"
19
+ RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
20
+
21
+ task :default => :spec
File without changes
@@ -0,0 +1,115 @@
1
+ module AuditedViewsHelper
2
+
3
+ def audited_controls(model)
4
+ render "controls", model: model
5
+ end
6
+
7
+ #Retorna audits para o model ou para todos os models caso o parâmetro for uma relation ou array
8
+ #Retorna audits para todos os associados aos models
9
+ def audits_for(models)
10
+ models = [models] unless models.kind_of?(Array) || models.kind_of?(ActiveRecord::Relation)
11
+ audits = []
12
+ models.each do |model|
13
+ audits += model.audits#.reject {|a| a.action =~ /create/ }
14
+ audits += model.associated_audits if model.respond_to?(:associated_audits)
15
+ end
16
+ audits.sort do |a,b|
17
+ b.created_at <=> a.created_at
18
+ end
19
+ end
20
+
21
+ def audit_link(model, text = nil)
22
+ text ||= I18n.t("audits.link_text")
23
+ unless params[:show_log]
24
+ puts "request.path: '#{request.path}'"
25
+ link_to "#{request.path}?show_log=true#audits", class: 'btn btn-default pull-right' do
26
+ text
27
+ end
28
+ end
29
+ end
30
+
31
+ def audit_object_info(audit)
32
+ classe = audit.auditable_type.constantize
33
+ content_tag(:span, title: "Id #{audit.auditable_id}") do
34
+ begin
35
+ begin
36
+ classe.find(audit.auditable_id).to_s
37
+ rescue
38
+ if classe.respond_to?(:with_deleted)
39
+ classe.with_deleted.find(audit.auditable_id).to_s
40
+ else
41
+ raise
42
+ end
43
+ end
44
+ rescue ActiveRecord::RecordNotFound => e
45
+ I18n.t(:registro_excluido, scope: 'audits')
46
+ end
47
+ end
48
+ end
49
+
50
+ def created_by_info(model)
51
+ html = []
52
+
53
+ html << t("audits.created_at")
54
+ html << ltime(model.created_at)
55
+ if (nome = get_model_creator(model))
56
+ html << t("audits.created_by")
57
+ html << nome
58
+ end
59
+
60
+ raw html.join(" ")
61
+ end
62
+
63
+ def ldate(date)
64
+ I18n.l(date, format: :data) if date
65
+ end
66
+
67
+ def ltime(time)
68
+ I18n.l(time, format: :short) if time
69
+ end
70
+
71
+ def format_audited_value(value)
72
+ case value
73
+ when true, false
74
+ t("audited.#{value}_word")
75
+ when Date
76
+ ldate value
77
+ when NilClass
78
+ "-"
79
+ when String
80
+ sanitize(value)
81
+ else
82
+ value
83
+ end
84
+ end
85
+
86
+ def get_model_creator(model)
87
+ model.audits.where(action: 'create').first.try(:user)
88
+ end
89
+
90
+ def created_by(model)
91
+ raw [nome_usuario(get_model_creator(model)), ltime(model.created_at)]
92
+ .compact
93
+ .delete_if(&:empty?)
94
+ .join(" - ")
95
+ end
96
+
97
+ def panel_class_for_audit_action(action)
98
+ case action
99
+ when "create" then "panel-success"
100
+ when "update" then "panel-info"
101
+ when "destroy" then "panel-danger"
102
+ else "panel-default"
103
+ end
104
+ end
105
+
106
+ def audit_record_human_field(audit_record, field)
107
+ # The most of reference field locales are defined only with the association name (not field name)
108
+ normalized_field = field.gsub(/_id$/, "")
109
+ audit_record
110
+ .auditable_type
111
+ .constantize
112
+ .human_attribute_name(normalized_field)
113
+ end
114
+
115
+ end
@@ -0,0 +1,4 @@
1
+ class Audit < ActiveRecord::Info
2
+ belongs_to :user, polypmorphic: true
3
+
4
+ end
@@ -0,0 +1,55 @@
1
+ <% if audit_record.audited_changes.find{|field, (old_value,new_value)| !old_value.blank? || !new_value.blank? } %>
2
+ <div class="panel <%= panel_class_for_audit_action(audit_record.action) %>">
3
+ <div class="panel-heading">
4
+ <b><%= t(audit_record.action, scope: "audits") %></b> -
5
+ <%= ltime audit_record.created_at %> -
6
+ <%= audit_record.user %>
7
+ </div>
8
+ <div class="panel-body">
9
+ <p>
10
+ <%= audit_record.auditable_type.constantize.model_name.human %>:
11
+ <b><%= audit_object_info(audit_record) %></b>
12
+ </p>
13
+
14
+ <table class="table audits">
15
+ <tr>
16
+ <th><%= t("audits.field") %></th>
17
+ <th><%= t("audits.old_value") %></th>
18
+ <th><%= t("audits.new_value") %></th>
19
+ </tr>
20
+ <% audit_record.audited_changes.each do |field, (old_value, new_value)| %>
21
+ <%# if !old_value.blank? || !new_value.blank? %>
22
+ <tr data-audited-field="<%= field %>">
23
+ <td>
24
+ <%= audit_record_human_field(audit_record, field) %>
25
+ </td>
26
+ <% if audit_record.action == "update" && audit_record.auditable_type.constantize.column_for_attribute(field.to_sym).type == :text %>
27
+ <td colspan="2" class="diff">
28
+ <%= sanitize Differ.diff(new_value, old_value).format_as(:html) %>
29
+ </td>
30
+ <% else %>
31
+ <td>
32
+ <% if audit_record.action == "create" %>
33
+ -
34
+ <% else %>
35
+ <%= format_audited_value old_value %>
36
+ <% end %>
37
+ </td>
38
+ <td>
39
+ <% if audit_record.action == "create" %>
40
+ <!-- #Como audited changes so possui um elemento no array de campos, aqui ele aparece no primeiro elemento, logo old_value do parametro do bloco -->
41
+ <%= format_audited_value old_value %>
42
+ <% elsif audit_record.action == "destroy" %>
43
+ -
44
+ <% else %>
45
+ <%= format_audited_value new_value %>
46
+ <% end %>
47
+ </td>
48
+ <% end %>
49
+ </tr>
50
+ <%# end %>
51
+ <% end %>
52
+ </table>
53
+ </div>
54
+ </div>
55
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <a name="audits"></a>
2
+ <hr>
3
+ <h2><%= t("audits.partial_title") %></h2>
4
+
5
+ <% audits_for(model).each do |audit| %>
6
+ <%= render partial: "audit_record", locals: {audit_record: audit} %>
7
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <hr>
2
+
3
+ <% if model.is_a?(ActiveRecord::Base) %>
4
+ <span class="audit-created-at">
5
+ <%= created_by_info(model) %>
6
+ </span>
7
+ <% end %>
8
+
9
+ <%= audit_link(model) %>
10
+ <%= render "audits", model: model if params[:show_log] %>
@@ -0,0 +1,19 @@
1
+ en:
2
+ audits:
3
+ field: Field
4
+ create: Creation
5
+ created_at: Created at
6
+ created_by: by
7
+ data_hora: Date/Time
8
+ destroy: Exclusion
9
+ link_text: Show Change Log
10
+ model: Table
11
+ new_value: New Value
12
+ old_value: Old Value
13
+ registro: Record
14
+ registro_excluido: Deleted Record
15
+ partial_title: Change Log
16
+ update: Update
17
+ usuario: User
18
+ true_word: Yes
19
+ false_word: No
@@ -0,0 +1,19 @@
1
+ pt-BR:
2
+ audits:
3
+ field: Campo
4
+ create: Criação
5
+ created_at: Registro criado em
6
+ created_by: por
7
+ data_hora: Data/Hora
8
+ destroy: Exclusão
9
+ link_text: Visualizar Log de Alterações
10
+ model: Tabela
11
+ new_value: Novo Valor
12
+ old_value: Valor Anterior
13
+ registro: Registro
14
+ registro_excluido: Registro Excluído
15
+ partial_title: Log de Alterações
16
+ update: Alteração
17
+ usuario: Usuário
18
+ true_word: Sim
19
+ false_word: Não
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ resources :products
3
+ end
@@ -0,0 +1,5 @@
1
+ require "audited_views/engine"
2
+
3
+ module AuditedViews
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ module AuditedViews
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module AuditedViews
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :audited_views do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,4 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Channel < ActionCable::Channel::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module ApplicationCable
2
+ class Connection < ActionCable::Connection::Base
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
@@ -0,0 +1,58 @@
1
+ class ProductsController < ApplicationController
2
+ before_action :set_product, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /products
5
+ def index
6
+ @products = Product.all
7
+ end
8
+
9
+ # GET /products/1
10
+ def show
11
+ end
12
+
13
+ # GET /products/new
14
+ def new
15
+ @product = Product.new
16
+ end
17
+
18
+ # GET /products/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /products
23
+ def create
24
+ @product = Product.new(product_params)
25
+
26
+ if @product.save
27
+ redirect_to @product, notice: 'Product was successfully created.'
28
+ else
29
+ render :new
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /products/1
34
+ def update
35
+ if @product.update(product_params)
36
+ redirect_to @product, notice: 'Product was successfully updated.'
37
+ else
38
+ render :edit
39
+ end
40
+ end
41
+
42
+ # DELETE /products/1
43
+ def destroy
44
+ @product.destroy
45
+ redirect_to products_url, notice: 'Product was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_product
51
+ @product = Product.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def product_params
56
+ params.require(:product).permit(:sku, :title, :price, :active, :description)
57
+ end
58
+ end