Looks like here is some mistake.
Suppose I have setting "allow_anonymous" = false in database, but true in defaults.
Then in initializes scripts will have access allowed instead of desired to be forbidden.
Initializes may require settings to start Rails (setup routes, for example).
Here are two options:
finish with exception if setting requested before Rails initialized;
do the best for get setting even if Rails not completely initialized yet (hooks or whatever).
Sorry to say, but silent return of default values from file instead of database is definitely mess.
I prefer to have second solution like this:
def rails_initialized?
return true if Rails.application && Rails.application.initialized?
return true if try(:consider_initialized?)
raise "Can't get values before initialization of Rails or #{self.name}.consider_initialized? successful return"
end
# Also remove conditional returning of defaults if not rails_initialized?
# End even better to convert it to some private method like .ensure_initialized!
Any case this situation should be highlighted in Readme.
What do you think? Need to apply such a patch?
Looks like here is some mistake. Suppose I have setting "allow_anonymous" = false in database, but true in defaults. Then in initializes scripts will have access allowed instead of desired to be forbidden. Initializes may require settings to start Rails (setup routes, for example).
Here are two options:
Sorry to say, but silent return of default values from file instead of database is definitely mess.
I prefer to have second solution like this:
Any case this situation should be highlighted in Readme. What do you think? Need to apply such a patch?