generator for attribute options
Hello @mrkamel
I was wondering if it would be possible to use a generator directly in the options of an attribute.
search_scope :search do
attributes person: [ "person.full_name", "person.display_name", "person.doc_id"]
options :person, left_wildcard: false
attributes partner_doc_id: ["person.doc_id" ]
options :partner_doc_id, raw_ilike: true
#...
generator :raw_ilike do |column_name, raw_value|
"( #{column_name} IS NOT NULL AND
regexp_replace(#{column_name}, '[^a-zA-Z0-9]+', '','g') ILIKE ('%' || regexp_replace('#{raw_value}', '[^a-zA-Z0-9]+', '','g') || '%')
)
"
end
end
I know the generator is designed for hash based queries, but it would be a very useful feature to be able to apply it directly to an attribute.
Hi, sry for the delayed response. Currently, it's not possible. I'm of course open for contributions, but i won't add it myself due to lack of time and i've no need for it.
Hi. Sorry for the delay here too. I understand your point. I'll study the code a bit and see if I can implement this. Anyway, thanks for your time.
I am going to try taking a stab at adding this functionality. Seems like a very useful feature.