Content
View differences
Updated by Eric Schubert over 1 year ago
### Information
* the custom values of custom fields of type list do have special handling in `act_as_searchable.rb`
```ruby
def build_custom_field_condition(custom_field_ids)
CustomValue.select("1")
.joins(<<~SQL.squish)
LEFT JOIN custom_options
ON custom_options.custom_field_id = custom_values.custom_field_id
AND custom_options.id::VARCHAR = custom_values.value
SQL
.where(customized_type: name, custom_field_id: custom_field_ids)
.where("customized_id=#{table_name}.id")
.where("(custom_values.value ILIKE ?) OR (custom_options.value ILIKE ?)")
end
```
* usually this kind of code should go into responsibility of the custom field itself
* the custom values of custom fields of type list do have special handling in `act_as_searchable.rb`
```ruby
def build_custom_field_condition(custom_field_ids)
CustomValue.select("1")
.joins(<<~SQL.squish)
LEFT JOIN custom_options
ON custom_options.custom_field_id = custom_values.custom_field_id
AND custom_options.id::VARCHAR = custom_values.value
SQL
.where(customized_type: name, custom_field_id: custom_field_ids)
.where("customized_id=#{table_name}.id")
.where("(custom_values.value ILIKE ?) OR (custom_options.value ILIKE ?)")
end
```
* usually this kind of code should go into responsibility of the custom field itself