【发布时间】:2015-05-01 07:04:30
【问题描述】:
我已在我的 Rails 应用程序中包含引导日期选择器。但它没有显示任何内容。请检查我的以下代码。
宝石文件:
source 'https://rubygems.org'
gem 'rails', '3.2.19'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
gem "bcrypt-ruby", :require => "bcrypt"
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'bootstrap-datepicker-rails', '>= 0.6.21'
#gem 'bootstrap-datepicker-rails'
gem 'will_paginate', '~> 3.0'
view_report.html.erb:
<div class="input-group bmargindiv1 date" id='datepicker' data-date-format="yyyy-mm-dd" data-date="2015-05-01" data-behaviour='datepicker' >
<%= form_tag reports_view_report_path, :method => 'get' do %>
<%= text_field_tag :search, params[:search], :class => "form-control", :onchange => 'this.form.submit();'%>
<% end %>
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
<script type="text/javascript">
$(function() {
$('#datepicker').datepicker()
});
</script>
</div>
application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>SwargadwaraPuri</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<link rel="stylesheet" href="/assets/bootstrap-2.0.css">
<link rel="stylesheet" href="/assets/plugins-2.0.css">
<link rel="stylesheet" href="/assets/main-2.0.css">
<link rel="stylesheet" href="/assets/themes-2.0.css">
</head>
<body class="login no-animation" >
<%= yield %>
<script src="/assets/bootstrap.min-2.0.js"></script>
<script type="text/javascript" src="/assets/bootstrap-filestyle.min.js"></script>
<script src="/assets/plugins-2.0.js"></script>
<script src="/assets/main-2.0.js"></script>
</body>
</html>
应用程序.js
//= require jquery
//= require jquery_ujs
//= require bootstrap-datepicker
//= require_tree .
//= require_self
application.css:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*=bootstrap-datepicker
*/
我需要像 yyyy-mm-dd 这样的日期格式。请帮我解决这个问题。我使用的是 Rails 版本 3.2.9。
【问题讨论】:
-
你得到的是哪种格式?
-
@Gagan:我根本没有日历。但我需要它应该采用这种格式 yyyy-mm-dd。
-
@satya 你需要显示在日期选择器中选择的当前日期吗?
-
@rick :当前日期也快到了。
标签: ruby datepicker ruby-on-rails-3.2