If this is my user controller, I can replace
def index
@users = User.all
end
withexpose(:users)
This definitely cleans up the code quite a bit. When things start getting hairy, you can redefine your expose method using a block, like so:
expose(:users) do
User.active
end
This will grab all active users in your database (assuming you have a scope, in your model, that grabs all active users).The gem does a lot more than I'm gonna cover here, I suggest taking a look at decent_exposure's github page for more info.
No comments:
Post a Comment