How could I perform some modification on all data asked of a model before it returns it? The callbacks in rails appear to only deal with creation or updating of data, not retreival.
I bet this is probably a very obvious solution I’m not seeing.
Here’s an example:
I have a table called quotes. Before any data is given by the Quote model, I’d like to replace all occurances of the word Sun Tzu with Chinese Dude.
Think of this a different way.
You want to change quote.text, so it returns the database value of text with the substitution applied.
Here’s the code
Thereby you only overwrite what you need.