I am building an application with Ruby 1.9.3 and Rails 3.0.9
I have a class like below.
module CDA
class Document
def humanize_class_name
self.class.name.gsub("::","")
end
end
end
I want the class name like "CDADocument".
Is my humanize_class_name method is the correct way to achieve this?
OR
Any other built in methods available with Rails?
If you using i18n
you can call Model.model_name.human
to get the localized model name.
E.g.: Event.model_name.human
returns my localized name.
Docs: http://api.rubyonrails.org/classes/ActiveModel/Name.html#method-i-human