Skip to content

Instantly share code, notes, and snippets.

@jugyo
Created October 17, 2011 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jugyo/1291907 to your computer and use it in GitHub Desktop.
Save jugyo/1291907 to your computer and use it in GitHub Desktop.
# Example:
#
# en:
# activerecord:
# events:
# localizer_test_model:
# close: "Let's close it!"
#
# states:
# localizer_test_model:
# open: "It's opened now!"
#
class AASM::Localizer
def human_state(obj)
klass = obj.class
defaults = ancestors_list(klass).map do |ancestor|
:"#{i18n_scope(klass)}.states.#{i18n_klass(ancestor)}.#{obj.aasm_current_state}"
end << obj.aasm_current_state.to_s.humanize
I18n.translate(defaults.shift, :default => defaults, :raise => true)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment