diff --git a/README.md b/README.md index 4ca6e3f..05169a9 100644 --- a/README.md +++ b/README.md @@ -375,10 +375,16 @@ which uses [Psych.safe_load](https://www.rubydoc.info/stdlib/psych/Psych.safe_lo LabTech requires permitting the following classes using [config.active_record.yaml_column_permitted_classes](https://guides.rubyonrails.org/configuring.html#config-active-record-yaml-column-permitted-classes): -- `Symbol` -- `Time` +- `ActiveSupport::Duration` - `ActiveSupport::TimeWithZone` - `ActiveSupport::TimeZone` +- `Symbol` +- `Time` + +*Note: this list is almost certainly incomplete!* + +If you discover new ones, please submit an issue or PR. (There's also a list +in ./lib/lab_tech/engine.rb that should be considered canonical.) ## Contributing diff --git a/lib/lab_tech/engine.rb b/lib/lab_tech/engine.rb index 2bde555..a7ea1e4 100644 --- a/lib/lab_tech/engine.rb +++ b/lib/lab_tech/engine.rb @@ -4,18 +4,29 @@ class Engine < ::Rails::Engine config.generators.api_only = true config.after_initialize do + # NOTE: this list also exists in the README; please try to keep them in sync. required_serializable_classes = [ ActiveSupport::Duration, ActiveSupport::TimeWithZone, ActiveSupport::TimeZone, - Time, + Symbol, + Time, ] - + missing_classes = required_serializable_classes - Rails.configuration.active_record.yaml_column_permitted_classes if missing_classes.any? - puts "Please add #{missing_classes.join(', ')} to your Rails.configuration.active_record.yaml_column_permitted_classes.".red - puts "LabTech will break your application horribly unless you do.".red + puts <<~EOF.red + + Please add the following classes to your + Rails.configuration.active_record.yaml_column_permitted_classes: + #{ missing_classes.map { |klass| " - #{klass}" }.join('\n') } + + Because LabTech uses ActiveRecord's `serialize` to save experimental + results to the database, running experiments is likely to break your + application horribly without this configuration. + + EOF end end end