diff options
author | Matt Hogan <OhHeyItsMatt@gmail.com> | 2015-01-05 09:02:44 -0600 |
---|---|---|
committer | Matt Hogan <OhHeyItsMatt@gmail.com> | 2015-01-05 09:02:44 -0600 |
commit | 7b910917d39bb7d7c5b1b7cdbfb14ff001cac7cc (patch) | |
tree | b4b4a37e3a631e402c54458461a15a270c3dfc01 /activerecord/lib | |
parent | ed21e18166774a8334d703634e15626691e6e5fa (diff) | |
download | rails-7b910917d39bb7d7c5b1b7cdbfb14ff001cac7cc.tar.gz rails-7b910917d39bb7d7c5b1b7cdbfb14ff001cac7cc.tar.bz2 rails-7b910917d39bb7d7c5b1b7cdbfb14ff001cac7cc.zip |
Fix TypeError in Fixture creation
Ruby 4.2 started doing `value.gsub('$LABEL', label)` for fixture label interpolation, but you can have have valid YAML where `label` isn't a String.
For example:
```YAML
0:
name: John
email: johndoe@gmail.com
1:
name: Jane
email: janedoe@gmail.com
```
This YAML will create a label that is a Fixnum, causing `TypeError: no implicit conversion of Fixnum into String.`
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/fixtures.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/fixtures.rb b/activerecord/lib/active_record/fixtures.rb index 3c71936c3b..5f6a75ebef 100644 --- a/activerecord/lib/active_record/fixtures.rb +++ b/activerecord/lib/active_record/fixtures.rb @@ -633,7 +633,7 @@ module ActiveRecord # interpolate the fixture label row.each do |key, value| - row[key] = value.gsub("$LABEL", label) if value.is_a?(String) + row[key] = value.gsub("$LABEL", label.to_s) if value.is_a?(String) end # generate a primary key if necessary |