controller_name classify constantize model_name

控制器

class CourseSurveysController < ResourcesBaseController

end
controller_name   # "course_surveys"
controller_name.singularize  # "course_survey"
controller_name.singularize.classify  # "CourseSurvey"
'Module'.constantize     # => Module(没"",不是字符串)
'Test::Unit'.constantize    # => Test::Unit(没"",不是字符串)
class Person < ActiveModel::Model
end Person.model_name # => Person
Person.model_name.class # => ActiveModel::Name
Person.model_name.singular # => "person"
Person.model_name.plural # => "people"
上一篇:JavaScript正则表达式学习笔记之一 - 理论基础


下一篇:【iCore3 双核心板】例程三十五:HTTP_IAP_ARM实验——更新升级STM32