Added option +taggable_model_type+ to +tagged_with+ scope #994
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
When searching for multiple tags on different contexts on a model which is actually a table view,
tagged_with
will be translated based on taggable model.On my particular case, this won't work as expected. The tags were created on the original model, not on the "table view" (this view is used for several calculations). I can't duplicate the tags on this table view as there will be a duplication of data.
Issue
ActsAsTaggableOn
will translate the query based ontaggable_model.base_class.name
which is the name of the table view, but not the table which actually is being referenced by that table view.Solution
I propose adding an optional parameter
taggable_model_type
totagged_with
method:By allowing to specify the
taggable_model_type
, the query will search tags on the correct table (and not on the view), and make the calculations on the table view as expected.