Skip to content

Instantly share code, notes, and snippets.

@ream88
Created June 9, 2011 11:58
Show Gist options
  • Save ream88/1016586 to your computer and use it in GitHub Desktop.
Save ream88/1016586 to your computer and use it in GitHub Desktop.
Translatable Concern
module Translatable
extend ActiveSupport::Concern
module InstanceMethods
def method_missing(*args)
method = /(\w+)(.)?/.match(args.first).to_a.last(2)
method = "#{method.first}_#{args.second}#{method.second}"
if respond_to?(method)
send(method)
else
super
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment