我一直在試圖遵循這一Railscast:http://railscasts.com/episodes/213-calendars更換導軌date_select使用jQuery UI
我已經實現了控制,所有的javscript工作...它加載日期到字段,它與提交params,但rails仍然在NULL字段中插入NULL。以下是日誌顯示的內容:
Started POST "/shifts" for 127.0.0.1 at 2011-06-16 12:52:24 -0400
Processing by ShiftsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"W1MmVDoKMuR3HKmql+dDdWXt70xmZ9bVOJgdUtb1lKQ=", "shift"=>{"shift_on"=>"06/23/2011", "state"=>"requested"}, "commit"=>"Create Shift"}
SQL (0.3ms) SELECT name
FROM sqlite_master
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
AREL (0.4ms) INSERT INTO "shifts" ("user_id", "shift_on", "state", "created_at", "updated_at") VALUES (NULL, NULL, 'requested', '2011-06-16 16:52:24.743149', '2011-06-16 16:52:24.743149')
Redirected to http://localhost:3000/shifts/1
Completed 302 Found in 274ms
shift_on
coloumn是日期類型。
這是我的形式:
<%= form_for(@shift) do |f| %>
<% if @shift.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@shift.errors.count, "error") %> prohibited this shift from being saved:</h2>
<ul>
<% @shift.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<%= f.label :shift_on %><br />
<%= f.text_field :shift_on %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
,這是我的application.js:
$(function() {
$("#shift_shift_on").datepicker();
});
有什麼想法?
我也能夠更新jquery:'dateFormat:'yy-mm-dd'' – Slick23 2011-06-16 21:19:58