Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion motion/cdq/relationship_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module CDQ

class CDQRelationshipQuery < CDQTargetedQuery

attr_reader :target_class

def initialize(owner, name, set = nil, opts = {})
@owner = owner ? WeakRef.new(owner) : nil
@relationship_name = name
Expand Down Expand Up @@ -132,7 +134,7 @@ def respond_to?(method)
end

def method_missing(method, *args, &block)
if @__query__.respond_to?(method)
if @__query__.target_class.respond_to?(method) || @__query__.respond_to?(method)
@__query__.send(method, *args, &block)
else
super
Expand Down
1 change: 1 addition & 0 deletions spec/cdq/relationship_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class << self

it "should be able to use named scopes" do
cdq(@author).articles.all_published.array.should == [@article1, @article2, @article3]
@author.articles.all_published.array.should == [@article1, @article2, @article3]
end

it "can handle many-to-many correctly" do
Expand Down