This project is archived and is in readonly mode.
Dynamic scopes and dynamic finders for belongs_to
-
Pratik
- Assigned user set to Michael Koziarski
-
Ryan Bates
I think it's preferable to go through the has_many association whenever possible. So you could do this in the first example.
comments = current_user.commentsBut for cases where you need to search on multiple belongs_to associations then I could see this being really useful.
-
Tom Locke
This seems to be a bit at risk of name clashes, the following slight change might help and is perhaps more readable:
Comment.creator_is(current_user)Then you can also have the negative form, e.g.:
my_post.comments.creator_is_not(some_user)I also have an implementation of these and many more which I'm intending to release as a plugin.
-
Ryan Bigg
Automatic cleanup of spam.
