我在使用此表单时遇到问题。 我没有得到数据字段:start_publish和:end_publish。 其他人都可以。 怎么会发生什么? 我需要一些帮助来完成这个。
Controller Upload erb
def create
@upload = Upload.new(upload_params)
@upload.key = Emission.find(params[:id]).key
@upload.upload_file = params[:file]
@upload.emission_id = params[:id]
end
def upload_params
#params.require(:upload).permit(:start_publish, :end_publish)
params.require(:file).permit(:start_publish, :end_publish)
end
端
表单上传erb
<%= form_for(@upload, html: { multipart: true, :id => 'my_form'}) do |f| %>
<% if @upload.errors.any? %>
<div class="bs-component">
<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<h4 class="messages">Error!</h4>
<ul>
<% @upload.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
</div>
<% end %>
<div class="form-horizontal">
<fieldset>
<legend><%= @title_form %></legend>
<div class="form-group">
<%= f.hidden_field :id_emission, :value => @emission.id %>
<%= f.label :start_publish, 'Inicio', :class => 'col-lg-2 control-label' %>
<div class="col-lg-10">
<%= f.text_field :start_publish, :class => 'form-control', :id => 'datetimepicker4' %>
</div>
</div>
<div class="form-group">
<%= f.label :end_publish, 'Fin', :class => 'col-lg-2 control-label' %>
<div class="col-lg-10">
<%= f.text_field :end_publish, :class => 'form-control', :id => 'datetimepicker5' %>
</div>
</div>
<div class="form-group">
<div class="dropzone dropzone-previews" id="my-awesome-dropzone">
<div id="dropzone">
<div class="dz-message">
<span class="message-int">
Arrastre los archivos desde su computador o haga click aquí .<br>
<span class="note">Por favor seleccione los archivos.</span>
<div class="fallback">
<%= f.file_field :file, multiple: true %>
</div>
</span>
</div>
</div>
<div class="dropzone-previews"></div> <!-- this is were the previews should be shown. -->
</div>
<%= f.submit 'Guardar', :class => 'btn btn-primary pull-right', :id => 'btn-submit' %>
</div>
<% end %>
<script type="text/javascript">
$(function () {
$('#datetimepicker4').datetimepicker({
format: 'DD/MM/YYYY H:mm'
});
});
$(function () {
$('#datetimepicker5').datetimepicker({
format: 'DD/MM/YYYY H:mm'
});
});
var urls = '<%= uploads_url() %>';
</script>