0

データベースでは、clientsテーブルに名前、電話番号、その他のデータがあります。しかし、Simple_formとの関連付けを作成すると、オプションに名前が表示されます。フォームのオプションに名前を表示する代わりに、電話を表示する方法はありますか?

これが私が現在使用している名前を表示するコードです。

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

1 に答える 1

0

label_methodパラメーターを渡して、適切な属性に設定できます。

<%= f.association :client, :required => false, :prompt => "Eliga Cliente", 
:label => "Clients", :collection => Client.where(:status => true).order("id ASC"),
:label_method => :phone %>
于 2012-10-02T15:51:30.797 に答える