I'm trying to use ransack
gem with acts_as_taggable
. I have a simple Job
model that configured acts_as_taggable
in a default way and has tag_list
property.
When I run:
Job.ransack("tags_name_in"=>["eum", "sint"]).result.to_sql
It generates SQL as expected (which is good):
"SELECT \"jobs\".* FROM \"jobs\" LEFT OUTER JOIN \"taggings\" ON \"taggings\".\"taggable_id\" = \"jobs\".\"id\" AND \"taggings\".\"context\" = 'tags' AND \"taggings\".\"taggable_type\" = 'Job' LEFT OUTER JOIN \"tags\" ON \"tags\".\"id\" = \"taggings\".\"tag_id\" WHERE \"tags\".\"name\" IN ('eum', 'sint')"
But when I'm trying to exclude by using:
Job.ransack("tags_name_not_in"=>["eum", "sint"]).result.to_sql
It throws exaptation:
NoMethodError: undefined method `left' for #<ActiveRecord::Relation::QueryAttribute:0x007f851ea6bcd8>
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/context.rb:190:in `block in build_correlated_subquery'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/context.rb:189:in `each'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/context.rb:189:in `build_correlated_subquery'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/ransack/nodes/condition.rb:9:in `block in arel_predicate'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/ransack/nodes/condition.rb:6:in `map'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/ransack/nodes/condition.rb:6:in `arel_predicate'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/visitor.rb:17:in `visit_Ransack_Nodes_Condition'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/visitor.rb:52:in `visit'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/visitor.rb:5:in `accept'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/ransack/visitor.rb:4:in `block in visit_and'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/ransack/visitor.rb:4:in `map'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/ransack/visitor.rb:4:in `visit_and'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/visitor.rb:24:in `visit_Ransack_Nodes_Grouping'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/visitor.rb:52:in `visit'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/visitor.rb:5:in `accept'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/ransack-1.8.2/lib/ransack/adapters/active_record/context.rb:37:in `evaluate'
... 12 levels...
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/commands/rails.rb:6:in `call'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/command_wrapper.rb:38:in `call'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/application.rb:191:in `block in serve'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/application.rb:161:in `fork'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/application.rb:161:in `serve'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/application.rb:131:in `block in run'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/application.rb:125:in `loop'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/application.rb:125:in `run'
from /Users/sashar/.rvm/gems/ruby-2.2.5/gems/spring-2.0.1/lib/spring/application/boot.rb:19:in `<top (required)>'
from /Users/sashar/.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/sashar/.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
Any ideas?