Skip to content

NoMethodError (undefined method `table_name' for an instance of Arel::Table) #47

@goosys

Description

@goosys

Using Rails 7.1.5 with Ransack 4.0.0 results in the following error:

NoMethodError (undefined method `table_name' for an instance of Arel::Table):
  
ransack (4.0.0) lib/ransack/adapters/active_record/context.rb:16:in `type_for'
ransack (4.0.0) lib/ransack/nodes/attribute.rb:35:in `type'
ransack (4.0.0) lib/ransack/nodes/condition.rb:266:in `default_type'
ransack (4.0.0) lib/ransack/nodes/condition.rb:25:in `extract'
ransack (4.0.0) lib/ransack/nodes/grouping.rb:175:in `write_attribute'
ransack (4.0.0) lib/ransack/nodes/grouping.rb:115:in `method_missing'
ransack (4.0.0) lib/ransack/search.rb:54:in `block in build'
ransack (4.0.0) lib/ransack/search.rb:48:in `each'
ransack (4.0.0) lib/ransack/search.rb:48:in `build'
ransack (4.0.0) lib/ransack/search.rb:40:in `initialize'
ransack (4.0.0) lib/ransack/adapters/active_record/base.rb:16:in `new'
ransack (4.0.0) lib/ransack/adapters/active_record/base.rb:16:in `ransack'
activerecord (7.1.5.1) lib/active_record/relation/delegation.rb:79:in `block in ransack'
activerecord (7.1.5.1) lib/active_record/relation.rb:939:in `_scoping'
activerecord (7.1.5.1) lib/active_record/relation.rb:467:in `scoping'
activerecord (7.1.5.1) lib/active_record/relation/delegation.rb:79:in `ransack'
/workspaces/administrate_ransack/lib/administrate_ransack/searchable.rb:32:in `prepare_search'
/workspaces/administrate_ransack/lib/administrate_ransack/searchable.rb:10:in `scoped_resource'
administrate (0.20.1) app/controllers/administrate/application_controller.rb:8:in `index'
actionpack (7.1.5.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
...

The current gemspec allows ransack >= 2.3, but this seems too old to be compatible with modern Rails versions. It might be better to raise the minimum version.

Testing revealed:

  • Rails 6.1 works with both Ransack 4.0.0 and 4.3.0 without errors.
  • Rails 7.1 works with Ransack 4.1.0 but fails with 4.0.0.

Based on this, I suggest updating the gemspec to require ransack >= 4.1.0 to ensure compatibility with Rails 7.1. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions