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

ransack_alias doesn't work in associations #1520

Open
matgaw opened this issue Aug 29, 2024 · 0 comments
Open

ransack_alias doesn't work in associations #1520

matgaw opened this issue Aug 29, 2024 · 0 comments

Comments

@matgaw
Copy link

matgaw commented Aug 29, 2024

class Parent
  ransack_alias :full_name, :first_name_or_last_name
end

class Child
  belongs_to :parent
end

Working scenario:

Parent.ransack(full_name_cont: 'a').result # works correctly

Error scenario:
Child.ransack(parent_full_name_cont: 'a').result
Result:

undefined method `type' for nil:NilClass (NoMethodError)

      attr.klass.columns.find { |column| column.name == name }.type
                                                              ^^^^^
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