2010-12-17 111 views

回答

1

如果你只是想操纵什么名字回报......这样做......

class Project < ActiveRecord::Base 
    def name 
    this_name = read_attribute(:name) 

    # do some stuff with this_name 

    this_name #return this_name 
    end 
end 
+0

我想要做的是采取正常返回一个整数字段,并能够to_s的调用它并执行查找并返回相应的字符串。所以如果整数返回1,那么to_s返回“active”。就像我说的,我知道我可以用助手做到这一点,但我想知道你是否可以在模型级别做到这一点。 – ryanbillingsley 2010-12-21 20:08:27

相关问题