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

Undefined method with predicates #1440

Closed
jlupox opened this issue Sep 26, 2023 · 1 comment
Closed

Undefined method with predicates #1440

jlupox opened this issue Sep 26, 2023 · 1 comment

Comments

@jlupox
Copy link

jlupox commented Sep 26, 2023

Rails 7.1.0.beta1
ransack 4

Controller:

@q = Customer.ransack(params[:q])
@customers = @q.result(distinct: true)

View:

  <%= search_form_for @q do |f| %>
    <%= f.label :name %>
    <%= f.search_field :name_cont %>

    <%= f.submit %>
  <% end %>
  <% @customers.each do |customer| %>
    <%= render customer %>
    <p>
      <%= link_to "Show this customer", customer %>
    </p>
  <% end %>

Error output:

undefined method `table_name' for #<Arel::Table:0x00007f3f8a7612d8 @name="customers", @klass=Customer(id: , name: , cif: , address: , postal_code: , town: , created_at: , updated_at: ), @type_caster=#<ActiveRecord::TypeCaster::Map:0x00007f3f8a9547e8 @klass=Customer(id: , name: , cif: , address: , postal_code: , town: , created_at: , updated_at: )>, @table_alias=nil>

Trace:

[ransack (4.0.0) lib/ransack/adapters/active_record/context.rb:16:in `type_for'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/nodes/attribute.rb:35:in `type'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/nodes/condition.rb:266:in `default_type'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/nodes/condition.rb:25:in `extract'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/nodes/grouping.rb:175:in `write_attribute'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/nodes/grouping.rb:115:in `method_missing'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/search.rb:54:in `block in build'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/search.rb:48:in `each'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/search.rb:48:in `build'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/search.rb:40:in `initialize'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/adapters/active_record/base.rb:16:in `new'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[ransack (4.0.0) lib/ransack/adapters/active_record/base.rb:16:in `ransack'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/abstract_controller/base.rb:224:in `process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_controller/metal/rendering.rb:165:in `process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/abstract_controller/callbacks.rb:259:in `block in process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/callbacks.rb:121:in `block in run_callbacks'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actiontext/lib/action_text/rendering.rb:23:in `with_renderer'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actiontext/lib/action_text/engine.rb:69:in `block (4 levels) in <class:Engine>'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/callbacks.rb:130:in `instance_exec'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/callbacks.rb:130:in `block in run_callbacks'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/callbacks.rb:141:in `run_callbacks'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/abstract_controller/callbacks.rb:258:in `process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_controller/metal/rescue.rb:25:in `process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_controller/metal/instrumentation.rb:74:in `block in process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/notifications.rb:206:in `block in instrument'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/notifications/instrumenter.rb:58:in `instrument'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/notifications.rb:206:in `instrument'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_controller/metal/instrumentation.rb:73:in `process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_controller/metal/params_wrapper.rb:261:in `process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activerecord/lib/active_record/railties/controller_runtime.rb:32:in `process_action'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/abstract_controller/base.rb:160:in `process'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionview/lib/action_view/rendering.rb:40:in `process'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_controller/metal.rb:227:in `dispatch'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_controller/metal.rb:309:in `dispatch'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/routing/route_set.rb:49:in `dispatch'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/routing/route_set.rb:32:in `serve'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/journey/router.rb:51:in `block in serve'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/journey/router.rb:32:in `each'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/journey/router.rb:32:in `serve'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/routing/route_set.rb:882:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack (3.0.8) lib/rack/tempfile_reaper.rb:20:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack (3.0.8) lib/rack/etag.rb:29:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack (3.0.8) lib/rack/conditional_get.rb:31:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack (3.0.8) lib/rack/head.rb:15:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/http/permissions_policy.rb:36:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/http/content_security_policy.rb:33:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack-session (2.0.0) lib/rack/session/abstract/id.rb:272:in `context'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack-session (2.0.0) lib/rack/session/abstract/id.rb:266:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/cookies.rb:689:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activerecord/lib/active_record/migration.rb:653:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/callbacks.rb:101:in `run_callbacks'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/callbacks.rb:28:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/executor.rb:14:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/actionable_exceptions.rb:16:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[web-console (4.2.1) lib/web_console/middleware.rb:132:in `call_app'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[web-console (4.2.1) lib/web_console/middleware.rb:19:in `block in call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[web-console (4.2.1) lib/web_console/middleware.rb:17:in `catch'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[web-console (4.2.1) lib/web_console/middleware.rb:17:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) railties/lib/rails/rack/logger.rb:37:in `call_app'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) railties/lib/rails/rack/logger.rb:24:in `block in call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/tagged_logging.rb:135:in `block in tagged'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/tagged_logging.rb:39:in `tagged'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/tagged_logging.rb:135:in `tagged'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) railties/lib/rails/rack/logger.rb:24:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/remote_ip.rb:92:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/request_id.rb:28:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack (3.0.8) lib/rack/method_override.rb:28:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack (3.0.8) lib/rack/runtime.rb:24:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/server_timing.rb:59:in `block in call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/server_timing.rb:24:in `collect_events'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/server_timing.rb:58:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/executor.rb:14:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/static.rb:25:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rack (3.0.8) lib/rack/sendfile.rb:114:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) actionpack/lib/action_dispatch/middleware/host_authorization.rb:141:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[rails (d56db8ff17cf) railties/lib/rails/engine.rb:529:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[puma (6.4.0) lib/puma/configuration.rb:272:in `call'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[puma (6.4.0) lib/puma/request.rb:100:in `block in handle_request'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[puma (6.4.0) lib/puma/thread_pool.rb:378:in `with_force_shutdown'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[puma (6.4.0) lib/puma/request.rb:99:in `handle_request'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[puma (6.4.0) lib/puma/server.rb:443:in `process_client'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[puma (6.4.0) lib/puma/server.rb:241:in `block in run'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
[puma (6.4.0) lib/puma/thread_pool.rb:155:in `block in spawn_thread'](http://localhost:9999/customers?q%5Bname%5D=asdf&commit=Search#)
@jlupox
Copy link
Author

jlupox commented Sep 26, 2023

I have checked the PR #1439
Ransack 4.0.0 is not working with Rails 7.1.0.beta1

@jlupox jlupox closed this as completed Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant