Make Rails throw an error if a required field is not set when it starts
konyu opened this issue · 2 comments
konyu commented
Is your feature request related to a problem? Please describe.
Anyway_config's required feature is great, but the function throws an error when an object is just initialized in Rails apps.
We don't realize to forget setting the required fields until initializing the object.
Describe the solution you'd like
I suggest the idea to make Rails fail if required items are not set in all Anyware_config inherited classes at the time of Rails after_initialize.
For the time being, to meet this requirement, I run the following script that initializes all classes inheriting from anyware_config.
The file is set under config/initializers.
files = Dir.glob("config/configs/*")
class_names = files
.reject { |str| str.include?("application_config") }
.map { |file_path| File.basename(file_path, ".rb").camelize }
class_names.each { |name| name.constantize.new }
palkan commented
This is a duplicate of this discussion: #121
Please, take a look at the proposed solutions and let's continue the discussion there.
konyu commented
OK, I'll see that.