How do I access the name of the Rails 3 application object?

后端 未结 8 926
礼貌的吻别
礼貌的吻别 2020-12-23 13:28

I need to know the name of a programmers application from within a Rails 3 engine.

8条回答
  •  [愿得一人]
    2020-12-23 13:57

    For a more "humanized" version (based on the first reply you can find here) consider the following method: it will return Test App for your TestApp application.

    def app_name
      Rails.application.class.parent_name
        .underscore
        .humanize
        .split
        .map(&:capitalize)
        .join(' ')
    end
    

提交回复
热议问题