Skip to content

Commit

Permalink
Fixed named queries error
Browse files Browse the repository at this point in the history
  • Loading branch information
gabynaiman committed Oct 4, 2016
1 parent d710a10 commit 4d55508
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/rasti/db/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def query(name, query=nil, &block)
queries[name] = query || block

define_method name do |*args|
result = Query.new(self.class, dataset, schema).instance_exec *args, &block
result = Query.new(self.class, dataset, schema).instance_exec *args, &self.class.queries[name]
result.respond_to?(:all) ? result.all : result
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/minitest_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class Posts < Rasti::DB::Collection
many_to_many :categories
one_to_many :comments

query :created_by do |user_id|
where user_id: user_id
end
query :created_by, -> (user_id) { where user_id: user_id }

query :entitled, -> (title) { where title: title }
query :entitled do |title|
where title: title
end
end

class Comments < Rasti::DB::Collection
Expand Down

0 comments on commit 4d55508

Please sign in to comment.