Ruby on rails 在rails中使用moment.js语言环境的正确方法是什么?
我正在按照这些链接更改日期选择器的区域设置,但它仍然不起作用 加载页面时没有控制台日志错误 链接:Ruby on rails 在rails中使用moment.js语言环境的正确方法是什么?,ruby-on-rails,momentjs,locale,Ruby On Rails,Momentjs,Locale,我正在按照这些链接更改日期选择器的区域设置,但它仍然不起作用 加载页面时没有控制台日志错误 链接: https://eonasdan.github.io/bootstrap-datetimepicker/#using-locales https://github.com/moment/moment 我的代码: gemfile gem 'momentjs-rails', '>= 2.9.0' gem 'bootstrap3-datetimepicker-rails', '~> 4.1
https://eonasdan.github.io/bootstrap-datetimepicker/#using-locales
https://github.com/moment/moment
我的代码:
gemfile
gem 'momentjs-rails', '>= 2.9.0'
gem 'bootstrap3-datetimepicker-rails', '~> 4.17.47'
application.js
//= require moment
//= require bootstrap-datetimepicker
//= require moment/pt-br
dashboard.js
$(document).ready(function () {
$('.datetimepicker').datepicker({
locale: 'pt-br'
});
});
html.erb文件:
<div class='col-md-6'>
<div class="form-group">
<%= label_tag :initial_date, 'Data Inicial' %>
<div class='input-group date' id='initial_date'>
<%= text_field_tag(:initial_date, @filter&.initial_date, class: "form-control datetimepicker", id: "datetimepicker", autocomplete: "off") %>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
如果您使用的是rails 5>0版本,我建议您使用Thread,在这里您可以看到一些有用的链接:
纱线添加力矩
是否应该改为$('.datetimepicker').datetimepicker(…)
?