I have got a bunch of records in locations
table:
...
*************************** 8. row ***************************
id: 8
feed: http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/4564.xml
...
*************************** 11. row ***************************
id: 11
feed: http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/5007.xml
...
With the help of this migration:
def self.up
add_column :locations, :old_feed, :string
Location.all.each do |l|
l.old_feed = l.feed
l.feed.sub!(/^.*?(\d+)\.xml$/, 'http://newsrss.bbc.co.uk/weather/forecast/\1/Next3DaysRSS.xml') # l.feed = l.feed.sub(...) does not make it any better
l.save!
end
end
I want to turn them into
...
*************************** 8. row ***************************
id: 8
feed: http://newsrss.bbc.co.uk/weather/forecast/4564/Next3DaysRSS.xml
old_feed: http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/4564.xml
...
*************************** 11. row ***************************
id: 11
feed: http://newsrss.bbc.co.uk/weather/forecast/5007/Next3DaysRSS.xml
old_feed: http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/5007.xml
...
What I get instead is
...
*************************** 8. row ***************************
id: 8
feed: http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/4564.xml
old_feed: http://newsrss.bbc.co.uk/weather/forecast/4564/Next3DaysRSS.xml
...
*************************** 11. row ***************************
id: 11
feed: http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/5007.xml
old_feed: http://newsrss.bbc.co.uk/weather/forecast/5007/Next3DaysRSS.xml
...
Looks like feed
and old_feed
somehow got swapped and I can't figure out why.
Rails 2.3.4, MySQL 5.0.
P.S.
I bet it is something stupidly obvious I'm missing here.