2016-03-02 53 views
1

我要顯示列表的建立如下基於字符串名稱的Rails - 類別列表

AppName  bundle 
ABCD  test_1.3.5.0_AdHoc.ipa 
ABCD  test_1.3.5.0_Store.ipa 
DAA   test_1.3.4.0_AdHoc.ipa 
DAA   test_1.3.4.0_Store.ipa 

對於應用ABCD,我應該表現出「AdHoc.ipa」,然後再「Store.ipa」

構建表

id:integer appname:string bundle:string created_at:datetime 

建表數據

+-----+--------------+----------------------------------------------------------------------------------+ 
| id | app_name | bundle                   | 
+-----+--------------+----------------------------------------------------------------------------------+ 
| 36 |   ABCD | test_1.3.5.0_AdHoc.ipa       | 
| 37 |   DAA | test_AdHoc_.ipa       | 
| 38 |   ABCD | test_1.3.5.0_Store.ipa       | 
| 39 |   DAA | test_1.3.5.0_Store.ipa       | 

我應該怎麼做到這一點?任何想法 ?

回答

0

使用.order並按照您想要的順序傳遞2列。
第一個app_name然後bundle

Build.all.order('app_name ASC, bundle ASC')