フォームの一部のパラメーターがデータベースに投稿されていないが、「null」として渡されているRailsでフォームを送信しています。投稿されていないパラメータは:starthour、:endhourであり、理由はわかりませんが、時々:rentend
私はそれを理解することができません..以下を参照してください
フォームビュー
<div class="gearside_date_top">
<%= form_for LineItem.new do |f| %>
<p><%= render :partial => "price" %> /
<%= f.select :day_or_hour, [['day', 'day'], ['hour', 'hour']], :id => 'day_or_hour' %>
</p>
</div>
<script>
$('#line_item_day_or_hour').change(function() {
if($('#line_item_day_or_hour').val() != 'hour') {
$('.hourlyshowhide').hide();
$('#gear_daily').show();
}
else {
$('.hourlyshowhide').show();//else it is shown
$('#gear_daily').hide();
}
});
</script>
<div class="gearside_date_main">
<h3 style="font-family: 'RockSaltRegular', 'JosefinSansStdLight', Helvetica, Arial, sans-serif;color: #71a41e; font-size: 16px; margin: 15px 0 5px 15px;">Rental Date</h3>
<%= f.text_field :rentstart, id: 'rentstart', :value => "Pickup" %>
<%= f.text_field :rentend, id: 'rentend', :value => "Drop Off" %>
<%= image_tag('calendar.png', :style => "float:left; padding-top: 8px") %>
<%= f.hidden_field :gear_id, :value => @gear.id %>
</br></br>
<div class="gear_time_schedule hourlyshowhide">
<span class="gear_time_schedule_container">
<%= f.label :starthour, 'Pick Up Time', class: 'labeltext' %>
<%= f.text_field :starthour, id: 'starthour', :value => "" %>
</span>
<span class="gear_time_schedule_container">
<%= f.label :endhour, 'Drop Off Time', class: 'labeltext' %>
<%= f.text_field :endhour, id: 'endhour', :value => "" %>
</span>
</div>
<%= f.submit "", id: 'rent_it' %>
<% end %>
</div>
<script>
$('#starthour').timepicker({ 'step': 15 });
$('#endhour').timepicker({ 'step': 15 });
</script>
ログファイル
Started POST "/line_items" for 127.0.0.1 at 2012-06-22 10:24:54 -0600
Processing by LineItemsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"MutF3dqAQpdtHtkvX1mTTxS+48styiHc1M94o8es3yA=", "line_item"=>{"day_or_hour"=>"hour", "rentstart"=>"06/05/2012", "rentend"=>"06/16/2012", "gear_id"=>"2"}, "commit"=>""}
[1m[36mCart Load (0.3ms)[0m [1mSELECT `carts`.* FROM `carts` WHERE `carts`.`id` = 28 LIMIT 1[0m
[1m[35mGear Load (0.2ms)[0m SELECT `gears`.* FROM `gears` WHERE `gears`.`id` = 2 LIMIT 1
[1m[36mLineItem Load (0.3ms)[0m [1mSELECT `line_items`.* FROM `line_items` WHERE `line_items`.`cart_id` = 28 AND `line_items`.`gear_id` = 2 LIMIT 1[0m
[1m[35m (0.1ms)[0m BEGIN
[1m[36m (0.6ms)[0m [1mUPDATE `line_items` SET `quantity` = 2, `updated_at` = '2012-06-22 16:24:54' WHERE `line_items`.`id` = 9[0m
[1m[35m (13.5ms)[0m COMMIT
[1m[36mCart Load (0.4ms)[0m [1mSELECT `carts`.* FROM `carts` WHERE `carts`.`id` = 28 LIMIT 1[0m
Redirected to http://localhost:3000/carts/28
Completed 302 Found in 76ms (ActiveRecord: 15.5ms)