0

I'm currently trying to migrate to activeadmin 3.0.0, which requires ransackable 4.3.0. This breaking change require to add ransackable_attributes and ransackable_associations as class methods in my models.

I have an Address model that I'm registering with active admin and I'm using the filters like this:

filter :street

I'm defining the ransackable_attributes in the Address model

  def self.ransackable_attributes(auth_object = nil)
    %w[street]
  end

This is supposed to be enough for the filters to work but instead I get an error that has to do with the predicate of the column.

undefined method `street_starts_with' for Ransack::Search<class: Address, base: Grouping <combinator: and>>:Ransack::Search
2
  • 1
    Are you sure 'street' exists in the model? Commented Nov 13 at 16:21
  • @dbugger I'm sure that 'street' is a db column for the address model. Commented Nov 14 at 6:47

1 Answer 1

0

I believe you're probably migrating from MetaSearch gem (Ransack predecessor).

_starts_with is not a predicate available in Ransack. On Ransack, it's just start (see it on the official docs).

_starts_with was the way to go in MetaSearch (ref). This project was already archived in favor of Ransack, it's not maintained anymore.

If you're seeing mentions to _starts_with on your logs, that probably indicates you have an issue with the migration itself (not on the way you're declaring your ransackable attributes).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.