mazikwyry
mazikwyry

Reputation: 197

ransack + AASM: ArgumentError wrong number of arguments (given 1, expected 0)

I faced the following error when running filtering using ransack:

ArgumentError wrong number of arguments (given 1, expected 0)

and stack trace is showing this:

object.ransack(query_params)

When dug deeper I have found that the error appears in aasm_create_scope method from the aasm gem.

query_params = {accepted: "value"}

What could go wrong?

Upvotes: 0

Views: 347

Answers (1)

mazikwyry
mazikwyry

Reputation: 197

The problem was that accepted is a scope provided by aasm which doesn't accept arguments. Ransack doesn't send an argument when the value is true or ignore the scope when it is set to false.

{ accepted: "true" } || { accepted: "false" }

would only make sense. Any other value will raise that error.

Upvotes: 0

Related Questions