码迷,mamicode.com
首页 > 其他好文 > 详细

controller_name classify constantize model_name

时间:2015-02-04 16:07:35      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

控制器

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"

 

controller_name classify constantize model_name

标签:

原文地址:http://www.cnblogs.com/tardis/p/4272340.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!