Skip to content

Instantly share code, notes, and snippets.

@justinfrench
Created October 24, 2012 21:21
Show Gist options
  • Save justinfrench/3948967 to your computer and use it in GitHub Desktop.
Save justinfrench/3948967 to your computer and use it in GitHub Desktop.
Using ActiveRecord::Relation in non AR classes
class NonActiveRecordModel
def initialize(relation)
@relation = relation
end
def do_stuff
@relation.some_association.where(...)
end
end
NonActiveRecordModel.new(some_relation_from_an_active_record_model).do_stuff
# => NoMethodError: undefined method `where' for #<Array:0x007fc73b155db0>
@rwz
Copy link

rwz commented Oct 25, 2012

Is this 3.2 or upcoming 4.0 behavior? Crazy inconsistent and weird, anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment