I found this article on cleaning up chained scopes that would be great in a project I'm working on. However, some of my scopes have arguments. I can't think of a way to make this work with arguments. I tried string interpolation which I suspected wouldn't work and of course, didn't.
def self.send_chain(methods)
methods.inject(self, :send)
end
$ methods = ["with_author", "pending_review", "draft", "flagged", "published", "with_website", "with_meta_title", "with_meta_description"]
$ Article.send_chain(methods)
Aucun commentaire:
Enregistrer un commentaire