Rails 4.2.3 と MySql 5.5.37 を使用しています。最近、列の名前とタイプを変更しましたが、Rails フォームを送信すると、そのフォーム フィールド「selection_id」がキャプチャされません。以下は私のRailsフォームです...
<div class="field">
<%= f.label :day %><br>
<%= f.hidden_field :day, :validate => true %>
<div id="datepicker"></div>
</div>
<div class="field">
<%= f.label :selection_id %><br>
<div class="styled-select"><%= collection_select(:user_selection, :selection_id, @selections, :id, :description, {:prompt => true}) %></div>
</div>
<div class="field">
<%= f.label :total %><br>
<%= f.text_field :total, :size => 4, :validate => true %>
</div>
そして、これがブラウザに出力されるHTMLです...
<div class="field">
<label for="user_selection_day">Day</label><br>
<input validate="true" type="hidden" value="02/07/2016" name="user_selection[day]" id="user_selection_day" />
<div id="datepicker"></div>
</div>
<div class="field">
<div class="field_with_errors"><label for="user_selection_selection_id">selection</label></div><br>
<div class="styled-select"><div class="field_with_errors"><select name="user_selection[selection_id]" id="user_selection_selection_id"><option value="">Please select</option>
<option value="3">option 1</option>
<option value="4">option 2</option></select></div></div>
</div>
<div class="field">
<label for="user_selection_total">Total</label><br>
<input size="4" validate="true" type="text" value="1" name="user_selection[total]" id="user_selection_total" />
</div>
このデータが Chrome に送信されているのがわかります...
user_selection[day]:02/19/2016
user_selection[selection_id]:3
user_selection[total]:9
しかし、コントローラー側でパラメーターを出力しようとすると、3つのうち2つだけが出力されます。これは「置く」
def create
@current_user = User.find(session["user_id"])
...
puts user_selection_params
版画
{"day"=>"02/19/2016", "total"=>"9"}
この他のフィールドが失われるのはなぜですか?どうすれば修正できますか?