2012-10-02 21 views
0

在數據庫中,clients表具有名稱,電話和其他數據。但是,如果我使用Simple_form創建了一個關聯,它將在選項中顯示名稱,是否有辦法顯示手機而不是在表單的選項中顯示名稱?使用Simple_form在數據庫中的數據庫中的特定字段中顯示信息

這是我目前使用的代碼顯示名稱。

<%= f.association :client, :required => false, :prompt => "Eliga Cliente", 
    :label => "Clients", :collection => Client.where(:status => true).order("id ASC") %> 

回答

0

您可以傳遞label_method參數並將其設置爲相應的屬性。

<%= f.association :client, :required => false, :prompt => "Eliga Cliente", 
:label => "Clients", :collection => Client.where(:status => true).order("id ASC"), 
:label_method => :phone %> 
+0

這工作完美!謝謝! – Phsyckr

相關問題