Class: ActiveRecord::Fixture
- Inherits:
-
Object
- Object
- ActiveRecord::Fixture
- Defined in:
- lib/composite_primary_keys/fixtures.rb
Instance Method Summary collapse
Instance Method Details
#find ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/composite_primary_keys/fixtures.rb', line 3 def find raise FixtureClassNotFound, "No class attached to find." unless model_class model_class.unscoped do # CPK #model_class.find(fixture[model_class.primary_key]) ids = self.ids(model_class.primary_key) model_class.find(ids) end end |
#ids(key) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/composite_primary_keys/fixtures.rb', line 13 def ids(key) if key.is_a? Array key.map {|a_key| fixture[a_key.to_s] } else fixture[key] end end |