Rails bootstrap 日期选择器不工作

Rails bootstrap Datepicker not working

我正在尝试将 datepicker 实现到 rails 应用程序,所以我已经能够 运行 它参考这两个链接:

http://jakoblaegdsmand.com/blog/2012/05/rails-datetime-picker/ https://github.com/Nerian/bootstrap-datepicker-rails

出于某种原因,当我 运行 使用脚手架时它 运行 很好,但是当我尝试通过从头构建 rails 应用程序来 运行 它时通过分别构建模型、控制器、视图而不是 运行ning,当我单击日期文本字段时基本上没有任何反应。

下面是我写的代码

在 Gemfile 中

gem 'bootstrap-datepicker-rails'

在appplication.css

*= require bootstrap-datepicker

在application.js

//= require bootstrap-datepicker

在_form.html.erb

<%= form_for(@category) do |f| %>
<%= f.label :Name %><br/>
<%= f.text_field :name %><br/>
<%= f.label :Description %><br/>
<%= f.text_area :description %><br/>
<%= f.label :EmailID %><br/>
<%= f.text_field :emailid %><br/>
<%= f.label :Date %><br/>
<%= f.text_field :cdate, :class => 'datepicker', 'placeholder'=> "dd-mm-yyyy" %><br/>

<script>
  $(function() {
    $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
});
  </script>
<% end %>

在Schema.rb


ActiveRecord::Schema.定义(版本:20150312163128)做</p>

<p>create_table"categories",强制::级联做|t|
    t.string "name"
    t.string "emailid"
    t.text "description"
    t.date "cdate"
    t.date时间"created_at",空:假
    t.date时间"updated_at",空:假
  结束</p>

<p>结束
</pre>

所以请告诉我做错了什么,因为 3 天以来一直停留在这个地方。

我检查了你的gihub link。你的顺序是错误的。 Jquery 和 jquery-ui 应该始终排在第一位。

//= require bootstrap-datepicker
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

尝试按如下方式更新:

//= require jquery
//= require jquery_ujs
//= require bootstrap-datepicker
//= require turbolinks
//= require_tree .