huacnlee / rails-settings-cached

Global settings for your Rails application.
Other
1.06k stars 202 forks source link

user.settings.all returns list of all settings of all users rather than specific user's #119

Closed nfedyashev closed 5 years ago

nfedyashev commented 7 years ago

Did anyone experienced this? I was rather surprised to see it:

RailsSettings::ScopedSettings.count == user.settings.all.count && user.settings.all.count == 739
   (0.8ms)  SELECT COUNT(*) FROM "settings"
   (0.5ms)  SELECT COUNT(*) FROM "settings"
   (0.6ms)  SELECT COUNT(*) FROM "settings"
 => true

SQL logs also shows that thing_id/thing_type is not used in SQL query completely, it returns settings of all users despite thing_id/thing_type references.

user is an instance of a regular ActiveRecord::Base class.(which contains include RailsSettings::Extend)

P.S. rails-settings-cached (0.6.2)

matwithers commented 5 years ago

Try using user.settings.get_all

Hope that helps