2017-05-19 8 views
0

私は選択した値を表示しようとしていますが、動作していないようです。何か案は?ここで選択肢desがレールで動作しない

はコードです:

<label>Apply to <%= statement_display_name.downcase %>:</label> <%= 
    f.select(:statement_id, 
    options_for_select(@client.statements.unpaid.collect { |statement| 
    [statement_display_name + " #{statement.number_with_prefix} # 
    {statement.created_or_bill_date.to_date} - # 
    {number_to_currency(statement.outstanding_amount)}"]}), :selected 
    => f.object.statement_id)%> 
+1

"動作していないようです"と詳しく説明できますか? –

+0

は、文IDで自動的にオプションを選択していないので、代わりにデフォルト値に戻ります。これが最初のものです。 – gerzon

答えて

0

あなたはオプションとして配列を渡しているが、あなたはこの仕事をするために代わりyour_string => statement_idのハッシュが必要になります。

オプションは、ステートメントIDをその値として参照しません。 [[some_string], [some_string]]の配列を渡しますが、おそらく必要でしょうが{some_string => statement_id, some_other_string => statement_id}

+0

あなたの答えをありがとう、それは問題を把握するのに役立ちました。 これは、それを整理: <%= select_tag:STATEMENT_ID、 options_for_select(@ client.statements.unpaid.collect {|声明| [statement_display_name +」 # {statement.created_or_bill_date.to_date} - # {number_to_currency(statement.outstanding_amount)} "]} params [:statement_id])、プロンプト:" ----- "%> – gerzon

+0

クール!あなたはそれにあなたの質問に返信し、答えとしてマークする必要があります:) – ttrmw

関連する問題