开发者

Get all from table AND sort?

Using the following code in my controller, I am able to retrieve all rows from my table, but it won't sort by the column last_name. Any sug开发者_JAVA技巧gestions?

 @pi_names = PiName.all(:order => 'pi_names.last_name DESC')


Try

 @pi_names = PiName.order('pi_names.last_name DESC').all


Alternative syntax allowing any errors to potentially be caught prior to runtime:

@pi_names = PiName.order(last_name: :desc)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜