Ransack accepts virtual attributes for belongs_to relationships

in my user.rb

ransacker :full_name do |parent|
    Arel::Nodes::NamedFunction.new('concat_ws', [' ', parent.table[:first_name], parent.table[:last_name]])
end

      

which grabs fields from User

 :first_name
 :last_name

      

and it works!

But I am also trying to search for users in projects, but I cannot figure out how to use ransacker to accomplish this

I get

 Mysql2::Error: Unknown column 'projects.first_name

      

how do I get it to search for users first_name and last_name instead of project

I've tried virtual attributes and it works in the console, but I get an unknown column when I try to use it with ransacker

Please help me Obi Wan, my only hope

+3


source to share





All Articles