Skip to content

Commit

Permalink
AR Extension for pluggable human model names
Browse files Browse the repository at this point in the history
  • Loading branch information
mzazrivec committed Dec 5, 2017
1 parent 29d1636 commit 297b27d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/extensions/ar_human_model_name.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module ActiveRecord
class Base
def self.human_model_name(number = 1)
n_(self.model_name.singular.titleize, self.model_name.plural.titleize, number)
end

def human_model_name(number = 1)
self.class.human_model_name(number)
end
end
end

0 comments on commit 297b27d

Please sign in to comment.