Topic: before_save callback
So after getting my head around regex, I finally have a string method I would like to use each time a document is created or updated. I have this method sitting inside of a String Helper:
downcase.sub(/^\./, 'dot-').gsub(/&/, '-and-').gsub(/\W|\s+/, '-').gsub(/[^a-zA-Z0-9_-]+/, '')
gsub(/:\/([a-z])\/+/, ':/terms/\1/').gsub(/(:\/1\/)+/, ':/terms/numbers/')
For the record, that permalink method is working perfectly, so I know this class is loading correctly. The problem is with the update_links method. Strangely enough I get it working just fine from the console like so:
>> t = Term.find_by_permalink('test')
The above gives me the desired result everytime, so I decide to use a callback to make sure the links are saved properly.
class Term < ActiveRecord::Base
I save, restart Mongrel, but no matter what I do, niether saving nor updating my term makes any difference.
Am I going about this all wrong?