The .search method conflicts with methods in other gems like Ransack
I suggest a rename og the .search method. The name is too generic and conflicts with other gems like https://github.com/activerecord-hackery/ransack
Ransack doesn't alias the search method if it is already defined and you can just use the original ransack method in that case. But actually we should could do something similar.
I get the same problem when define such enum:
class AdvertiserChannelMapping < ApplicationRecord
enum mkt_channel: {
organic: "Organic",
emai: "Email",
facebook: "Facebook",
other_paid: "Other Paid",
test: "Test",
search: "Search",
mobile_display: "Mobile Display"
}
end
gems/activerecord-5.0.6/lib/active_record/enum.rb:228:in `raise_conflict_error': You tried to define an enum named "mkt_channel" on the model "AdvertiserChannelMapping", but this will generate a class method "search", which is already defined by Active Record. (ArgumentError)
I solved the issue by next dirty hack config/initializers/textacular.rb:
module Textacular
undef :search
end
I think we can make this (adding methods to model) configurable and also introduce non-invasive wrapper like Textacular(MyModel).basic_search('ABC'). WDYT?