TIL #merge
is a thing on AR models.
Useful for joining + using a named scoped on the joined table:
class Post; end
class Comment; scope :approved, -> {approved: true}; end
Post.joins(:comments).merge(Comment.approved)
(defun add-project-to-projectile-known-projects (_ directory) | |
(projectile-add-known-project directory)) | |
(advice-add 'magit-clone :after 'add-project-to-projectile-known-projects) |
TIL #merge
is a thing on AR models.
Useful for joining + using a named scoped on the joined table:
class Post; end
class Comment; scope :approved, -> {approved: true}; end
Post.joins(:comments).merge(Comment.approved)
class TestDouble | |
attr_accessor :instance, :when_stack | |
def initialize(instance) | |
@instance = instance | |
@when_stack = [] | |
end | |
def when(&block) | |
fake_method_call = FakeMethodCall.new(block) |