【发布时间】:2010-11-18 02:41:23
【问题描述】:
我有一个这样的模块:
module Controller
module LocaleModels
def self.included(base)
base.send :include, InstanceMethods
end
module InstanceMethods
def locale_Lexeme; constantize_model('Lexeme') end
def locale_Synthetic; constantize_model('Synthetic') end
def locale_Property; constantize_model('Property') end
private
def constantize_model(common_part)
eval(I18n.locale.capitalize + '::' + common_part).constantize
end
end
end
end
但我一直得到
NoMethodError (undefined method `constantize' for #<Class:0x2483b0c>)
我想我不能在自定义模块中使用“constantize”。
但是你能提供一些解决方法吗?
【问题讨论】:
标签: ruby-on-rails module