1
我有日期時間場模型渲染後的新觀點,並提交其保存到數據庫中,除了日期時間場模型的各個領域,甚至我使用日期時間選擇器不能日期時間字段保存到數據庫
可以在任何身體幫我解決這個問題
這是我的工作代碼:
採訪控制器
def new
@interview = Interview.new(:batch_id => @batch.id)
end
def create
@interview = Interview.new(interview_params)
# Save the object
if @interview.save
# If save succeeds, redirect to the index action
flash[:notice]= "تم إنشاء المقابلة بنجاح."
redirect_to(interviews_path(:batch_id => @batch.id))
else
# If save fails, redisplay the form so user can fix problems
render('new')
end
end
專訪新視圖代碼
<% @page_title = "إنشاء مقابلة" %>
<div id="content-header">
<div class='header-icon hr-icon'></div>
<h1>المقابلات</h1>
<div class='header-sep'>|</div>
<div class='sub-header'>إنشاء مقابلة</div>
<div id="inner-tab-menu">
<ul>
<li class='themed_bg themed-dark-hover-background'><%= link_to("<< العودة للجدول", interviews_path(:batch_id => @batch.id)) %></li>
</ul>
</div>
</div>
<div id="page-yield">
<div class="iterviews new">
<%= form_for(@interview, :url =>interviews_path(:batch_id => @batch.id)) do |f| %>
<%= render(:partial => 'form', :locals => {:f => f}) %>
<script type="text/javascript">
$(function() {
$('#datetimepicker1').datetimepicker();
locale: 'ar-sa'
});
</script>
<div><%= f.submit("إنشاء مقابلة", :class => 'submit_button') %></div>
<% end %>
</div>
</div>
表單代碼
<div class="label-field-pair">
<div class="right-column">
<label for="student_grade">رقم المقابلة<span class="necessary-field">*</span> </label>
<div class="text-input-bg"><%= f.text_field(:code, style: "width: 240px;") %></div>
</div>
</div>
<div class="label-field-pair">
<div class="right-column">
<label for="student_grade">تاريخ المقابلة<span class="necessary-field">*</span></label>
<div class="text-input-bg" style="direction: ltr; margin: 0 10px 0 0;">
<div class='input-group date' id='datetimepicker1'>
<%= f.datetime_field(:interview_date , class: "form-control", style: "width: 200px;margin: 0;") %>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
<%= f.hidden_field(:batch_id, value: @batch.id) %>
嗯,這是不可能的,沒有看到實際的代碼... –
開發人員回答這類問題似乎太難了!!!!! –