2012-04-02 29 views
8

Aynı ada sahip bir özniteliğin bulunduğu ActiveRecord nesnesinde bir yöntemi çağırmaya çalışıyorum. Bu, SystemStackError: stack level too deep hatayla sonuçlanır.ActiveRecord nesne özellik adı, yöntem adıyla aynı

Nesne niteliğini değiştirmek için yöntem içinden nasıl erişebilirim?

def first_name 

return self.first_name.upper 

end 

cevap

21

bu kullanabileceğiniz bir Active Record modelse read_attribute yöntem

def first_name 
    read_attribute(:first_name).upper 
end 
İlgili konular