New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor UserController#search_users #57
Conversation
Love it. Any idea why it doesn't merge cleanly? Also would you mind filling out our CLA: http://www.discourse.org/cla @SamSaffron this approach keeps the SQL but isolates it from the controller. I vastly prefer it but would be more comfortable with your approval before merging. |
@eviltrout I created the branch around nine hours ago. If it doesn't merge then you guys must have been busy in that time. :) I'll update on master and re-push. |
FWIW, an accompanying blog explaining the thought behind this change here. |
Just wanted to say thanks for an awesome blog post explaining why you did it. It's one thing to link to some code on twitter, it's another to submit a patch to fix it and a detailed blog post of why. I am super impressed, and will happily merge this once @SamSaffron has a chance to review. |
|
Great changes, thanks so much, blowmage! One minor comment is that UserSearch is a service class, not really a model. It belongs in lib, imho. |
It models searching for a User. Sounds like a model to me. (Regardless, I think service classes belong in |
A word on
That would allow me to add new capabilities in a non-destructive way. So if a pure arel search was added, it could look like the following:
That said, I got sleepy and never got that far. I'm still not sure if an arel/ActiveRecord::Relation implementation is wanted, so I figured I'd submit this anyway and see what happened. I suppose this info would be better in a commit message than a comment on the pull request, but there you go. ¯_(ツ)_/¯ |
@blowmage seems like a good choice. I was just about to ask why you decided for a class instead of a module. Your last comment reminded me of this codeclimate blog post http://blog.codeclimate.com/blog/2012/11/14/why-ruby-class-methods-resist-refactoring/ |
I am totally fine with this, more test, more readable code, big wins for Discourse |
|
Refactor UserController#search_users
…-toc-view [#87059006] Reformat TOC to match updated wireframe
Move the SQL generation behind an intention revealing name, add tests.