Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve subs logging #5908

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/admin/order_cycles_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Admin
class OrderCyclesController < ResourceController
include OrderCyclesHelper
include PaperTrailLogging

prepend_before_action :set_order_cycle_id, only: [:incoming, :outgoing]
before_action :load_data_for_index, only: :index
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/admin/schedules_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

module Admin
class SchedulesController < ResourceController
include PaperTrailLogging

before_action :adapt_params, only: [:update]
before_action :editable_order_cycle_ids_for_create, only: [:create]
before_action :editable_order_cycle_ids_for_update, only: [:update]
Expand Down Expand Up @@ -140,7 +142,7 @@ def sync_subscriptions
end

def permitted_resource_params
params.require(:schedule).permit(:id, :name)
params.require(:schedule).permit(:id, :name, order_cycle_ids: [])
end
end
end
17 changes: 17 additions & 0 deletions app/controllers/concerns/paper_trail_logging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

# This concern adds additional Papertrail logging options so that the id of the
# user that modified the record is also logged.
# See: https://github.com/paper-trail-gem/paper_trail#setting-whodunnit-with-a-controller-callback

module PaperTrailLogging
extend ActiveSupport::Concern

included do
before_action :set_paper_trail_whodunnit
end

def user_for_paper_trail
spree_current_user
end
end