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 )
精彩评论