开发者

selecting specific fields in rails 3.0.1 by using find_by_id method

开发者 https://www.devze.com 2023-04-12 07:03 出处:网络
i would like to select specific field with alias names by method find_by_id , like using the following query

i would like to select specific field with alias names by method find_by_id , like using the following query

Model.find_by_id(params) # I am getting  all the table columns, 
                         # but i would开发者_运维技巧 like to have only some columns
                         # with alias names.

can you please help me to achieve this?


Model.select('column_name as alias').find_by_id(params)

Unless I am misunderstanding your question.

0

精彩评论

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