-
Notifications
You must be signed in to change notification settings - Fork 190
Closed
Description
Define scope on ActiveHash class and calling it, seems polluting original object.
reproduce
class Country < ActiveHash::Base
self.data = [
{:id => 1, :name => "US"},
{:id => 2, :name => "Japan"}
]
scope :east_asia, -> do
where(name: "Japan")
end
end
irb(main):054:0> c = Country.all
=>
#<ActiveHash::Relation:...
irb(main):055:0> c.count
=> 2
irb(main):056:0> c.east_asia
=>
#<ActiveHash::Relation:...
irb(main):057:0> c.count
=> 1
expected behavior
c.count should returns 2 because ActiveRecord scope returns new relation and do not affect to self.
environment
irb(main):058:0> ActiveHash::gem::VERSION
=> "3.1.1"
irb(main):063:0> Rails::VERSION::STRING
=> "7.0.3.1"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels