Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃毃 fix for "_table_exists?" method #208

Open
guyanbiao opened this issue May 21, 2021 · 4 comments
Open

馃毃 fix for "_table_exists?" method #208

guyanbiao opened this issue May 21, 2021 · 4 comments

Comments

@guyanbiao
Copy link

Hi huacnlee, Thanks for your gem, it's quite handy, But there is a potential issue here.

In the code here https://github.com/huacnlee/rails-settings-cached/blob/main/lib/rails-settings/base.rb#L157
the method will rescue all the errors.

It would be very bad if the application can't read the correct settings either because of timeout or something else and then get the default value instead, since these settings could be used to control the business flow, the default value could be very different from the production one.

I suggest just rescue specific errors such as "DB not exist" to let it go through the migration step and expose other errors to the application.

@huacnlee
Copy link
Owner

Do you used Setting.key in migrations?

@guyanbiao
Copy link
Author

nope

@guyanbiao
Copy link
Author

My point is better to raise exceptions instead of return a default value silently if can't read settings from the database.

@monachi
Copy link

monachi commented Jul 15, 2021

we have to override this, to let it raise exceptions, instead of falling back to default values

    def _table_exists?
      table_exists?
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants