ernie/ransack — Issue #35: Ransack doesn't like :through relationships (through a polymorphic at least..)
Author: morgz
Created: 2011-10-20 17:34:08+00:00
State: open

Firstly.. fantastic gem. It's really helping me out!

I have one problem though.

-------------------

class Management < ActiveRecord::Base

has_many :instructor_owners, :as => :owner
has_many :instructors, :through => :instructor_owners, :dependent => :destroy

...

In a controller when I try to access

@management.instructors.search(params[:q])

It blows up with:

undefined method `table_aliases' for #

This seems to be an issue with :through associations... I having success with any other kind of association.

Full Trace:

ransack (0.5.8) lib/ransack/adapters/active_record/context.rb:133:in `block in build_join_dependency'
ransack (0.5.8) lib/ransack/adapters/active_record/context.rb:132:in `each'
ransack (0.5.8) lib/ransack/adapters/active_record/context.rb:132:in `build_join_dependency'
ransack (0.5.8) lib/ransack/adapters/active_record/context.rb:97:in `join_dependency'
ransack (0.5.8) lib/ransack/context.rb:33:in `initialize'
ransack (0.5.8) lib/ransack/context.rb:17:in `new'
ransack (0.5.8) lib/ransack/context.rb:17:in `for_class'
ransack (0.5.8) lib/ransack/context.rb:11:in `for'
ransack (0.5.8) lib/ransack/search.rb:18:in `initialize'
ransack (0.5.8) lib/ransack/adapters/active_record/base.rb:15:in `new'
ransack (0.5.8) lib/ransack/adapters/active_record/base.rb:15:in `ransack'
activerecord (3.1.0) lib/active_record/relation.rb:455:in `block in method_missing'
activerecord (3.1.0) lib/active_record/relation.rb:180:in `block in scoping'
activerecord (3.1.0) lib/active_record/base.rb:1190:in `with_scope'
activerecord (3.1.0) lib/active_record/relation.rb:180:in `scoping'
activerecord (3.1.0) lib/active_record/relation.rb:455:in `method_missing'
activerecord (3.1.0) lib/active_record/associations/collection_proxy.rb:102:in `method_missing'
app/controllers/admin/instructors_controller.rb:15:in `index'
actionpack (3.1.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.0) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.1.0) lib/active_support/callbacks.rb:470:in `_run__2755570935726632965__process_action__4180327824903482234__callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.0) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.0) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.0) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.0) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.0) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.0) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.0) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
activerecord (3.1.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.1.0) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.0) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.0) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.0) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:110:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:531:in `call'
lib/api_defender.rb:48:in `call'
warden (1.0.5) lib/warden/manager.rb:35:in `block in call'
warden (1.0.5) lib/warden/manager.rb:34:in `catch'
warden (1.0.5) lib/warden/manager.rb:34:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.3) lib/rack/etag.rb:23:in `call'
rack (1.3.3) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/flash.rb:243:in `call'
rack (1.3.3) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.3) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/cookies.rb:326:in `call'
activerecord (3.1.0) lib/active_record/query_cache.rb:62:in `call'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.0) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.3) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.0) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.3) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.0) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.3) lib/rack/lock.rb:15:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.0) lib/rails/engine.rb:455:in `call'
railties (3.1.0) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.0) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.3) lib/rack/handler/webrick.rb:59:in `service'
/Users/morgz/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/morgz/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/morgz/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'