-
Notifications
You must be signed in to change notification settings - Fork 0
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
Move search logic from controller into model #25
base: dry-up-posts-controller
Are you sure you want to change the base?
Conversation
if type == "needed" || type == "available" | ||
send(type.to_sym) | ||
else | ||
all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason I'm not able to find docs for an 'all' method anywhere. I can infer what it's doing, but is this a builtin for rails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just like calling Post.all
, but since we're within Post
, we can just say all
. This lets us chain them.
For example, you can say Post.where(id: [1,2,3,4,5]).all.all.all.all
and it just returns the where
.
http://apidock.com/rails/ActiveRecord/Scoping/Named/ClassMethods/all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why I didn't realize this haha. Probably would have answered that immediately by opening a terminal :P.
👌 @mi-wood ? |
lgtm 👯 |
Eventually we should consider making a Search class, but for now this is OK I think :)