If you need to call process_pages
only once after Creating a Page
record and not after Updating a Page record then I would suggest to use after_create
instead.
class Page < ActiveRecord::Base
require 'open-uri'
after_create :process_pages
def process_pages
self.html = open(self.url).read
self.save
end
end
With after_save :process_pages
, process_pages
method would be called every time you save a Page record. You are saving a Page record again within process_pages
method which triggers the after_save
callback and you start looping.
See this SO Question for difference between after_save and after_create. You will understand better as to why you are going in loops.