It occurs to me that YAML could be a real boon here. I.e. define your
mappings via YAML (or XML but who does that anymore? grin). Probably
define it as something simple like:
then read it into a very similar hash table to what you have, maybe
reversing the keys if need be.
I think it would be cool to have an “acts_as_smiley” plugin. Maybe
something where you could do:
class Post < ActiveRecord::Base
acts_as_smiley :body, :icons => “myicons” # (this would be a subdir
of “images” in public)
Then, “underneath the covers”, it redefines the body accessor so that
it returns the smiley-parsed value of :body.
I could even imagine some other hooks like defining additional
accessors, like :body_nosmiley or :body_smiley that skips or runs the
Just a thought. Anyway, glad you got it working!