huacnlee / rails-settings-cached

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

New named scope for finding records with a setting with a specific value #94

Closed dangerous closed 8 years ago

dangerous commented 8 years ago

This adds a scope which allows us to find items which have a setting with a specific value. It works just like with_settings_for but rather than just passing var you also pass value.

# returns a scope of users having a 'color' setting with value 'red'
User.with_setting_value('color', 'red')
codecov-io commented 8 years ago

Current coverage is 97.93%

Merging #94 into master will increase coverage by +0.08% as of 51aa1df

@@            master     #94   diff @@
======================================
  Files            7       7       
  Stmts          233     242     +9
  Branches         0       0       
  Methods          0       0       
======================================
+ Hit            228     237     +9
  Partial          0       0       
  Missed           5       5       

Review entire Coverage Diff as of 51aa1df

Powered by Codecov. Updated on successful CI builds.

dangerous commented 8 years ago

I just saw that someone else submitted a new scope and it never got merged ( https://github.com/huacnlee/rails-settings-cached/pull/29/files ). When you look at this, if you decide not to merge it can you let me know, and if possible, let me know why or whether you want something changed in order to get it merged. At the moment I am pointing my Gemfile to my fork of this gem, but if it's never going to get merged it would make more sense for me to put the scope into a concern within my app and just continue to use your gem as is.

Thanks

huacnlee commented 8 years ago

You can add this scope in your User model, I don't want add any more complex code into this gem.

dangerous commented 8 years ago

No worries - thanks for letting me know 👍