BerserkHippo
BerserkHippo

Reputation: 37

Rails 4 Creating Scopes with Application Level Variables

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?

Upvotes: 0

Views: 42

Answers (1)

goreorto
goreorto

Reputation: 302

You can use

.where(nil) 

as replacement

Upvotes: 1

Related Questions