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

Add parent class name to additional options for report data #2640

Merged
merged 1 commit into from Nov 7, 2017
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
Expand Up @@ -5,6 +5,7 @@ class ApplicationController
:model,
:match_via_descendants,
:parent_id,
:parent_class_name,
:parent_method,
:association,
:view_suffix
Expand All @@ -16,6 +17,7 @@ def self.from_options(options)
additional_options.with_model(options[:model]) if options[:model]
additional_options.match_via_descendants = options[:match_via_descendants]
additional_options.parent_id = options[:parent].id if options[:parent]
additional_options.parent_class_name = options[:parent].class.name if options[:parent]
additional_options.association = options[:association]
additional_options.view_suffix = options[:view_suffix]
additional_options.parent_method = options[:parent_method]
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/application_helper.rb
Expand Up @@ -1639,6 +1639,11 @@ def from_additional_options(additional_options)
if additional_options[:match_via_descendants].present?
additional_options[:match_via_descendants] = additional_options[:match_via_descendants].constantize
end
if additional_options[:parent_id].present? && additional_options[:parent_class_name].present?
parent_id = from_cid(additional_options[:parent_id])
parent_class = additional_options[:parent_class_name].constantize
additional_options[:parent] = parent_class.find(parent_id) if parent_class < ActiveRecord::Base
end
additional_options
end

Expand Down