Open lapitsky opened 3 years ago
What version of acts-as-taggable-on
are you using?
@tannerhallman 7.0.0 Thank you for checking!
@lapitsky it works fine with rails 6.1.1 for me. are you by any chance setting table_name
to include the public
schema? the default behavior for table_name
is to return the unadorned table name, as you can see below. rails has builtin support to recognize order('table.column')
as safe, but doesn't recognize order('schema.table.column')
as safe. might want to report this to the rails maintainers.
Oh, I see. I think this is because we use apartment
gem that explicitly specifies public.
prefix. Thank you for the response!
Looks like this is resolved and needs to be closed.
Issue
Starting with Rails 6.1, I cannot tag an entity that has an ordered list of tags using an owner object.
Details
When I try to tag an entity with a list of comma-separated taggings like below
I get the following error
The entity uses
acts_as_ordered_taggable_on :positions
. This issue is caused by https://github.com/mbleigh/acts-as-taggable-on/blob/master/lib/acts_as_taggable_on/taggable/ownership.rb#L45. In Rails 6.1 in order to sort by an expression likepublic.taggings.id
we need to wrap the expression inArel.sql
call. This way we will let Rails know that this is a safe expression in terms of SQL injection.