spotlight icon indicating copy to clipboard operation
spotlight copied to clipboard

Engine-generated example code in spotlight_initializer.rb fails

Open mephillips-durham opened this issue 2 years ago • 0 comments

If you generate a new default application based on the Spotlight engine, the config/initializers/spotlight_initializer.rb file includes these lines:

#Spotlight::Engine.config.upload_fields = [
#  UploadFieldConfig.new(
#     field_name: config.upload_description_field,
#     label: -> { I18n.t(:"spotlight.search.fields.#{config.upload_description_field}") },
#     form_field_type: :text_area
#   ),
#   UploadFieldConfig.new(
#     field_name: :spotlight_upload_attribution_tesim,
#     label: -> { I18n.t(:'spotlight.search.fields.spotlight_upload_attribution_tesim') }
#   ),
#   UploadFieldConfig.new(
#     field_name: :spotlight_upload_date_tesim,
#     label: -> { I18n.t(:'spotlight.search.fields.spotlight_upload_date_tesim') }
#   )
#]

If you want to customise the global fields in your application, and uncomment these lines to retain the default fields in preparation to adding more, you will find they do not work. They need to look more like this:

Spotlight::Engine.config.upload_fields = [
  Spotlight::UploadFieldConfig.new(
     field_name: Spotlight::Engine.config.upload_description_field,
     label: -> { I18n.t(:"spotlight.search.fields.#{Spotlight::Engine.config.upload_description_field}") },
     form_field_type: :text_area
   ),
...

See similar example in Stanford's Exhibits application.

mephillips-durham avatar Nov 20 '23 12:11 mephillips-durham