Skip to content

Instantly share code, notes, and snippets.

@takkkun
Created May 24, 2013 08:23
Show Gist options
  • Select an option

  • Save takkkun/5642089 to your computer and use it in GitHub Desktop.

Select an option

Save takkkun/5642089 to your computer and use it in GitHub Desktop.
module Arel::AliasAttribute
def alias_attribute(new_name, old_name)
attribute_aliases.update(new_name.to_s => old_name.to_s)
end
def [](name)
super attribute_aliases[name.to_s] || name
end
def attribute_aliases
@attribute_aliases ||= {}
end
end
Arel::Table.__send__(:prepend, Arel::AliasAttribute)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment