I'm trying to create full text search on an Event model. The model contains a country_code field where the country code is stored; I want to be able to search by country directly by typing the country name, let's say France instead of Fr.
My scope looks like this:
pg_search_scope :full_search, against: [:name, :city, :country], associated_against: {
event_type: [:name],
dance_types: [:name]
}
I have a country method
def country
return '' if country_code.blank?
country = ISO3166::Country[country_code]
(country.translations[I18n.locale.to_s] || country.name) unless country.nil?
end
Unfortunately calling my search scope produces the following error:
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column events.country does not exist.
How can I fix this?