Written by Sean Behan on Sun Jun 17th 2012

Using the Acts as Taggable On plugin to add categories to a model class, I wanted to override the to_param method and place the name attribute in the url. The plugin, installed as a gem, source shouldn't need to be hacked in order to accomplish this. The solution is to add a plugin into the RAILS_ROOT/vendor/plugins directory and append the plugin name with _hack. This will, because of an alphabetical load order, allow you to reopen the any class in the plugin. In my example

# RAILS_ROOT/vendor/plugins/acts_as_taggable_on_hack/init.rb
Tag.class_eval do
  to_param
    "#{id}-#{name.gsub(/[^a-z0-9]+/i, '-'/)
  end
end
Got this tip from http://errtheblog.com/posts/67-evil-twin-plugin.

Tagged with..
#acts as taggable on #load order #plugins #Rails #to_param #Programming

Just finishing up brewing up some fresh ground comments...