0

It's possible that I was never doing this properly, but it was working in Rails 3, and now that .scoped is gone it no longer works.

Essentially I have a field in the User table who's value is used to filter almost all other data in the app. In Rails 3 I was using current_user.field_name in the ApplicationController and created methods that used .scoped that were in turn used as before_filter in controllers.

Now that .scoped is gone I need a solution and it probably makes sense to figure out the right way to do this.

To summarize what I need to do:

I need to get a value based on a field for the currently logged in user and then filter a bunch of models based on that value. Is this possible and what is the proper way to do it?

  • 1
    *created methods that used .scoped* I'm not sure I'm clear on what you were doing; can you give an example of how you were using `scoped` originally? – Paul Richter Mar 05 '15 at 15:46
  • possible duplicate of [With Rails 4, Model.scoped is deprecated but Model.all can't replace it](http://stackoverflow.com/questions/18198963/with-rails-4-model-scoped-is-deprecated-but-model-all-cant-replace-it) – Baldrick Mar 05 '15 at 19:56

1 Answers1

1

You can use

.where(nil) 

as replacement

goreorto
  • 302
  • 2
  • 9