renuo / hotsheet

Manage your database with a simple and familiar web interface
https://rubygems.org/gems/hotsheet
MIT License
103 stars 3 forks source link

Fetch all models automatically when not specified in config #19

Open simon-isler opened 3 weeks ago

simon-isler commented 3 weeks ago

currently we only load models that are defined in the configuration.

# frozen_string_literal: true

Hotsheet.configure do |config|
  config.model :Author do |model|
    model.included_attributes = %i[name birthdate gender created_at]
  end

  config.model :Post do |model|
    model.excluded_attributes = %i[id author_id created_at updated_at]
  end

  config.model :TableNameTest do |model|
    model.included_attributes = %i[]
  end

  config.model :VeryLongModelNameForOverflowTest do
    nil
  end
end

in this case, we would only show the configured models in the web.

so, it would be nice to have two additional global settings:

the following table shows an example which models should be configured depending on the included_models and excluded_models config settings: included_models excluded_models ActiveRecord models
nil nil fetch all
["Author"] nil or [] only "Author"
[] nil or [] nothing, due to empty included_models
nil ["Author"] fetch all except "Author"