开发者

Refer to a field (Model.field) with a variable (@field)

I have a variable called @field that is set to 开发者_如何学Goequal a field name, like @field = "city".

How can I use that variable to access Model.city? Literally, how can I get Model.@field to work?


Using send. Model.send( @field )

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜