Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arnaudbesnier/44ac9a3c870c9084901daf0d695b1594 to your computer and use it in GitHub Desktop.
Save arnaudbesnier/44ac9a3c870c9084901daf0d695b1594 to your computer and use it in GitHub Desktop.
Example of a Forest Smart Field on Rails
class Forest::Customer
include ForestLiana::Collection
collection :customers
search_fullname = lambda do |query, search|
first_name, last_name = search.split
query.where_values.first << " OR (firstname = '#{first_name}' AND lastname = '#{last_name}')"
query
end
field :fullname, search: search_fullname , type: 'String' do
"#{object.firstname} #{object.lastname}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment