开发者

Rails: accessing field value from model method

Where title is a field on the table in the database开发者_StackOverflow中文版, why does calling @title return nil?

Unbelievably, accessing model fields from inside a method on that model is undocumented.


Think about how you would access the info from outside the model:

model_instance.field_name

Therefore, from within the model you simply call

field_name

you can call instance methods from within that instance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜