Suggestion: create an 'acts_as_sluggable' method on activerecord::base
Closed this issue · 2 comments
hazah commented
I think it could be as simple as:
# Activate Slugalicious on all models
ActiveSupport.on_load(:active_record) do
self.instance_eval do
def self.acts_as_sluggable
include Slugalicious
end
end
end
RISCfuture commented
EDIT: Misunderstood comment.
Neat idea, but it's 6 or 7 lines of code for a net savings of 0 lines of code :)
hazah commented
Sorry to be beating a horse that seems dead... The main thought is along the lines of consistency (amongst rails plugins the 'acts_as' paradigm seems the norm) It looks better in code when things are somewhat grouped (I tend to have the acts_as stuff bunched up away from other model functions). Personal reasons aside, there is one benefit I can see with this little modification:
ActiveSupport.on_load(:active_record) do
self.instance_eval do
def self.acts_as_sluggable
include Slugalicious *args, &block
slugged *args, &block
end
end
end
This would at least save 1 line of client code :). Anyway. I leave it up to you. I too favour small (very small) foot-prints, but sometimes consistency wins for me.