Reputation: 3880
I have a model POSTS
. in that i have two scopes in this model active
, inactive
. i want use one of it PostsController
based on params[:active]
value. like following
if params[:active] == "true"
@posts = POSTS.where some_condition
.include some_thing
.active
.page
.per
else
@posts = POSTS.where some_condition
.include
.inactive
.page
.per
end
is there any better way to do the same thing? i tried many ways to do it. but i couldn't. help me. thanks
Upvotes: 0
Views: 44
Reputation: 121010
@posts = POSTS.where some_condition
.include some_thing
.public_send(params[:active] == "true" ? :active : :inactive)
.page
.per
Upvotes: 4