Created
October 24, 2012 21:21
-
-
Save justinfrench/3948967 to your computer and use it in GitHub Desktop.
Using ActiveRecord::Relation in non AR classes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this 3.2 or upcoming 4.0 behavior? Crazy inconsistent and weird, anyway.